我一直在开发一个简单的Android应用程序。
它在几个虚拟设备和HTC One S上运行良好,但是当我在Android 4.0.4的三星Galaxy Tab 2上启动它时,布局上的所有元素都是重复的。它可以通过虚拟键盘看到,没有它。
这是布局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/password_label"
android:layout_gravity="center_horizontal" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:id="@+id/password_view" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ok_label"
android:id="@+id/password_confirm"
android:layout_gravity="center_horizontal"
android:onClick="checkPassword" />
</LinearLayout>
活动源代码:
public class PasswordActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_password);
Button button = (Button) findViewById(R.id.password_confirm);
if (SharedPreferencesHandler.isPreferenceSet(this, SharedPreferencesHandler.PreferenceKey.PASSWORD_PREFERENCE_KEY)) {
button.setText(R.string.ok_label);
} else {
button.setText(R.string.save_label);
}
EditText editText = (EditText) findViewById(R.id.password_view);
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_DONE) {
checkPassword();
handled = true;
}
return handled;
}
});
}
//some utility methods
}
以下是该错误的屏幕截图: