relativelayout中的Textview和按钮在android oreo和pie中不可见,但在其他Android版本中完全可见。
if (mPromocodeCheckBox != null) {
mPromocodeCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (inputMethodManager == null)
inputMethodManager = (InputMethodManager) ALTCommonUtils.currentActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (mPromocodeLayout != null) {
if (isChecked) {
mPromocodeLayout.setVisibility(View.VISIBLE);
if (inputMethodManager != null && mPromocodeEditText != null) {
mPromocodeEditText.requestFocus();
inputMethodManager.showSoftInput(mPromocodeEditText, InputMethodManager.SHOW_IMPLICIT);
}
if (mPromocodeApplyButton != null)
mPromocodeApplyButton.setVisibility(View.VISIBLE);
if (mPromocodeEditText != null)
mPromocodeEditText.setEnabled(true);
} else {
mPromocodeLayout.setVisibility(View.GONE);
HandleViewsUtils.TextView_SetText(mPromocodeMsg, "");
if (inputMethodManager != null && mPromocodeEditText != null) {
HandleViewsUtils.EditText_SetText(mPromocodeEditText, "");
inputMethodManager.hideSoftInputFromWindow(mPromocodeEditText.getApplicationWindowToken(), 0);
}
}
}
}
});
}
你的xml截图很难读,但我刚刚意识到你正在使用fill_parent而不是match_parent。之后,API 8中不推荐使用FILL_PARENT; Google Developer Documentation Source。 Why you should use Match Parent。
也许是时候你转向最近推出的方法,设计模式和库。开始使用约束布局而不是相对布局。 Benefits of Constraint Layout及其introduction in Android Studio 2.2开始。停止使用相对布局并仅在非常必要时使用它们。关于布局的2018年Google I / O谈话,Link。您不知道Google何时会决定弃用它,然后您将有停止工作的项目。
另外要记住的是新的支持库AndroidX,您应该开始迁移旧项目。 AndroidX将成为未来的新奇异支持库,所有基于奇数的支持库都将停止使用。
最重要的是你应该开始开发Android API 28+,这将从今年开始由Google强制执行;谷歌开发者Youtube Video。因此,开始迁移到当前的API和支持库。
希望这可以帮助。
附录确保您的代码库上的Android Studio警告有关弃用的信息。这里有更多链接;