如两个屏幕截图所示,我在Activity布局中有3个editTexts。 当我触摸第一个(Message1)时,虚拟键盘会显示为人们应该期待的。 尽管如此,第一个editText现在几乎看不见了。
这是我的布局xml:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.n.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<View
android:layout_width="1dp"
android:layout_height="30dp" >
</View>
<EditText
android:id="@+id/message1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Message1"
android:gravity="center"
android:singleLine="true"
android:ellipsize="end" />
<View
android:layout_width="1dp"
android:layout_height="30dp" >
</View>
<EditText
android:id="@+id/message2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Message2"
android:gravity="center"
android:singleLine="true"
android:ellipsize="end" />
<View
android:layout_width="1dp"
android:layout_height="30dp" >
</View>
<EditText
android:id="@+id/sw"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="sw"
android:gravity="center"
android:singleLine="true"
android:ellipsize="end" />
<View
android:layout_width="1dp"
android:layout_height="30dp" >
</View>
<Button
android:id="@+id/d"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dip"
android:layout_marginRight="25dip"
android:text="d"
android:drawablePadding="10dip"
android:layout_gravity="center" />
<View
android:layout_width="1dp"
android:layout_height="200dp" >
</View>
</LinearLayout>
</ScrollView>
请帮助解决这种糟糕的UI行为。
此致
PS:不要让虚拟键盘ios的自定义设计误导你。我们在这里谈论的是Android,问题甚至在定制之前就已经发生了。
答案 0 :(得分:0)
尝试将此添加到清单文件下的相关活动中:
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"