[英]Android: Views within scroll view are hidden by keyboard
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:id="@+id/uploadedVideo"
android:layout_width="match_parent"
android:layout_height="224dp" />
<TextView
android:id="@+id/tvPath"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/uploadedVideo"
android:padding="5dp"
android:lines="1"
android:hint="choose video"/>
<EditText
android:id="@+id/etTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tvPath"
android:hint="Your title here"/>
<EditText
android:id="@+id/etDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/etTitle"
android:hint="Your description here"/>
<Button
android:id="@+id/btnUpload"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="upload"/>
</RelativeLayout>
</ScrollView>
</LinearLayout>
我如上所述创建了一个布局。 这里的问题是,当我单击编辑文本并弹出键盘时,滚动视图仅被拉伸很小,因此键盘隐藏了编辑文本。 该按钮移到关键字上方,但同样是键盘隐藏的两个编辑文本。
保持Scrollview为父级,可以在键盘启动时使两个editText都可见。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:id="@+id/uploadedVideo"
android:layout_width="match_parent"
android:layout_height="224dp" />
<TextView
android:id="@+id/tvPath"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/uploadedVideo"
android:padding="5dp"
android:lines="1"
android:hint="choose video"/>
<EditText
android:id="@+id/etTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tvPath"
android:hint="Your title here"/>
<EditText
android:id="@+id/etDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/etTitle"
android:hint="Your description here"/>
<Button
android:id="@+id/btnUpload"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="upload"/>
</LinearLayout>
</ScrollView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.