我有一项活动,在屏幕上显示小于1页的数据。 因此,当我按下屏幕上的编辑框时,键盘会隐藏UI组件(在它下面)。
问题是没有启用滚动(因为数据不足)。 如何强制滚动?
答案 0 :(得分:1)
您应该使用ScrollView环绕布局。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/editText1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="text" >
<requestFocus />
</EditText>
</LinearLayout>
</ScrollView>