android - 如果 ScrollView 仅支持一个直接子级,我应该如何使整个布局可滚动?

我在一个布局中有 3 个 TextView ,其中文本在我的 droid 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>

最佳答案

只需使用 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>

https://stackoverflow.com/questions/4259607/

相关文章:

c# - 很好地显示时间跨度

python - 如何使用 .format() 打印字符串,并在替换的字符串周围打印文字花括号

powershell - 使用格式表控制列宽

formatting - 我可以在 specflow 中更改 Gherkin 格式样式吗?

c - 如何打印有限数量的字符?

xml - 将每个 XQuery 结果放在一个新行上

java - java中具有可变数量参数的字符串格式

formatting - .NET GUID 大写字符串格式

css - 无法使用 class=pull-right 或 float :right 向右浮动 tw

visual-studio - 如何在 Visual Studio 中自动格式化 XAML 代码?