简体   繁体   中英

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>

I created a layout as above. The problem here is, when I click the edit texts and the keyboard comes out, the scroll view is stretched only little so the edit texts are hidden by the keyboard. The button moves above the keyword, but again it's the two edit texts that are hidden by the keyboard.

Keeping Scrollview as parent is making both editText visible when the keyboard is up.

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM