ScrollView中的FragmentTabHost隐藏了选项卡内容

时间:2015-03-18 17:50:32

标签: android uiscrollview

我需要将FragmentTabHost包裹在ScrollView周围,因为键盘会掩盖EditText。但是当我在ScrollView中放置FragmentTabHost时,它会折叠tabcontent,如下所示:

在添加ScrollView之前: enter image description here

添加ScrollView后: enter image description here

activity.xml

<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="match_parent"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="140dp"
            android:layout_height="140dp"
            android:layout_gravity="center_horizontal"
            android:layout_marginBottom="30dp"
            android:layout_marginTop="30dp"
            android:background="@color/White">

            <TextView
                android:id="@+id/tvBalance"
                android:layout_width="wrap_content"
                android:layout_height="60dp"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="30dp"
                android:background="@color/TransparentWhite"
                android:textColor="#72C171"
                android:textSize="45sp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/tvBalance"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="15dp"
                android:background="@color/TransparentWhite"
                android:text="@string/balance"
                android:textColor="#6D6D6D"
                android:textSize="20sp" />
        </RelativeLayout>

        <android.support.v4.app.FragmentTabHost
            android:id="@android:id/tabhost"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="0"
                    android:orientation="horizontal" />

                <FrameLayout
                    android:id="@android:id/tabcontent"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1" />

            </LinearLayout>
        </android.support.v4.app.FragmentTabHost>

    </LinearLayout>
</ScrollView>

检查片段tabcontent.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/tvPaymentsNote"
        android:layout_alignParentTop="true">

        <EditText
            android:id="@+id/etAddress1"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/edit_text_bg"
            android:ems="10"
            android:hint="@string/address1"
            android:inputType="text" />

        <EditText
            android:id="@+id/etAddress2"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_alignLeft="@id/etAddress1"
            android:layout_alignRight="@id/etAddress1"
            android:layout_below="@id/etAddress1"
            android:layout_marginTop="5dp"
            android:background="@drawable/edit_text_bg"
            android:ems="10"
            android:hint="@string/address2"
            android:inputType="text" />

        <EditText
            android:id="@+id/etZip"
            android:layout_width="150dp"
            android:layout_height="60dp"
            android:layout_alignLeft="@id/etAddress1"
            android:layout_below="@id/etAddress2"
            android:layout_marginRight="5dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/edit_text_bg"
            android:ems="10"
            android:hint="@string/zip"
            android:inputType="text" />

        <EditText
            android:id="@+id/etCountry"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@id/etZip"
            android:layout_alignRight="@id/etAddress1"
            android:layout_alignTop="@id/etZip"
            android:layout_below="@id/etAddress2"
            android:layout_toRightOf="@id/etZip"
            android:background="@drawable/edit_text_bg"
            android:ems="10"
            android:hint="@string/country"
            android:inputType="text">

            <requestFocus />
        </EditText>
    </RelativeLayout>

    <TextView
        android:id="@+id/tvPaymentsNote"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/btnSubmit"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="20dp"
        android:text="@string/payments_note"
        android:textColor="#7E7E7E"
        android:textSize="16sp" />

    <Button
        android:id="@+id/btnSubmit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:background="@drawable/greenbtn"
        android:text="@string/submit"
        android:textColor="@color/White" />

</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

也许尝试为android:fillViewport="true"设置ScrollView