如果ScrollView只支持一个直接子项,那么我应该如何使整个布局可滚动?

Sap*_*app 13 xml formatting android dimensions scrollview

我在布局中有3个文本视图,其中文本在我的机器人2的底部有点剪辑...如何确保整个文本是可见的,并且用户可以向下滚动(只需用他们的手指),看到我的其他文字?

谢谢!

编辑:

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ImageButton android:id="@+id/ImageButton01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/def" 
    android:layout_gravity="top|center">
    </ImageButton>

<TextView android:id="@+id/oneView" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="@string/one_def" 
android:layout_gravity="left|center" 
android:textSize="13dip"></TextView>

<TextView android:text="@string/two_def" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="left|center" 
android:id="@+id/twoView" 
android:textSize="13dip"></TextView>

<TextView android:text="@string/threedef_def" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="left|center" 
android:id="@+id/threeView" 
android:textSize="13dip"></TextView>


</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

Vit*_*nko 27

用ScrollView包装当前的LinearLayout.所以它应该是这样的:

<?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:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageButton ... />
        <TextView ... />
        <TextView ... />
        <TextView ... />

    </LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)


Mik*_*key 13

ScrollView的直接子节点应该是支持多个子节点的另一种布局,例如RelativeLayout或LinearLayout.