为什么我的ScrollView被隐藏了?

时间:2013-09-07 21:47:15

标签: android

像往常一样与ScrollViews战斗......

这是我的XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
 >

<ScrollView
    android:id="@+id/scinputscrollbar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/buttonscontainer"
    android:fadeScrollbars="false"
    android:fastScrollEnabled="true" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

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

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:gravity="center_horizontal"
                android:padding="5dp"
                android:text="@string/congratsinput"
                android:textAppearance="?android:attr/textAppearanceSmall" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:gravity="center_horizontal"
                android:padding="5dp"
                android:text="@string/inputting"
                android:textAppearance="?android:attr/textAppearanceSmall" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:padding="5dp"
                android:text="@string/inputsite"
                android:textAppearance="?android:attr/textAppearanceSmall" />

            <EditText
                android:id="@+id/editText1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:ems="10"
                android:padding="5dp"
                android:singleLine="true" >

                <requestFocus />
            </EditText>

            <TextView
                android:id="@+id/textView5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:padding="5dp"
                android:text="@string/inputoterinfo"
                android:textAppearance="?android:attr/textAppearanceSmall" />

            <com.examples.android.calendar.ActionEditText
                android:id="@+id/editText2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:imeOptions="actionDone"
                android:inputType="textMultiLine"
                android:padding="5dp" />

            <CheckBox
                android:id="@+id/checkBox1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:padding="5dp"
                android:text="@string/yesreminders"
                android:textAppearance="?android:attr/textAppearanceSmall" />
        </LinearLayout>
    </LinearLayout>
</ScrollView>

<LinearLayout
    android:id="@+id/buttonscontainer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:layout_weight="1"
        android:background="@drawable/roundrectanglebutton"
        android:padding="5dp"
        android:text="@string/ok"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <Button
        android:id="@+id/button2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:layout_weight="1"
        android:background="@drawable/roundrectanglebutton"
        android:padding="5dp"
        android:text="@string/no"
        android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>

</RelativeLayout>

这是我得到的结果......

enter image description here

这是理想的结果:

enter image description here

感谢您的帮助!

3 个答案:

答案 0 :(得分:1)

尝试将ScrollView的高度设置为match_parent

答案 1 :(得分:1)

尝试将android:fillViewport="true"添加到您的ScrollView

编辑:

此外,您不需要RelativeLayout。如果您只希望ScrollViewLinearLayout一个高于另一个,请将RelativeLayout替换为LinearLayout,并将orientation设置为{{1} }}

答案 2 :(得分:0)

最后,这种配置可以产生预期的结果:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"
android:layout_height="fill_parent"
 >

<ScrollView
    android:id="@+id/scinputscrollbar"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:fadeScrollbars="false"
    android:fastScrollEnabled="true"
    android:layout_above="@+id/buttonscontainer"
     >

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

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:gravity="center_horizontal"
            android:padding="5dp"
            android:text="@string/congratsinput"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:gravity="center_horizontal"
            android:padding="5dp"
            android:text="@string/inputting"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:padding="5dp"
            android:text="@string/inputsite"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:ems="10"
            android:padding="5dp"
            android:singleLine="true" >

            <requestFocus />
        </EditText>

        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:padding="5dp"
            android:text="@string/inputoterinfo"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <com.examples.android.calendar.ActionEditText
            android:id="@+id/editText2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:imeOptions="actionDone"
            android:inputType="textMultiLine"
            android:padding="5dp" />

        <CheckBox
            android:id="@+id/checkBox1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:padding="5dp"
            android:text="@string/yesreminders"
            android:textAppearance="?android:attr/textAppearanceSmall" />
    </LinearLayout>
</ScrollView>

<LinearLayout
    android:id="@+id/buttonscontainer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:orientation="horizontal" 
    android:layout_alignParentBottom="true"
    >

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:layout_weight="1"
        android:background="@drawable/roundrectanglebutton"
        android:padding="5dp"
        android:text="@string/ok"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <Button
        android:id="@+id/button2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:layout_weight="1"
        android:background="@drawable/roundrectanglebutton"
        android:padding="5dp"
        android:text="@string/no"
        android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>

</RelativeLayout>