安卓中的滚动条

3

我该如何在Android XML文件中添加滚动条?

有人能够提供一个简单的方法来在相对布局中添加它吗?

我尝试过很多次在相对布局和线性布局中添加它。

但是,它不起作用。

请给我解决方案。

谢谢。

2个回答

3

将你的相对布局或线性布局放在一个ScrollView中。例如:

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

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

        <!-- contents of linear layout go here -->
    </LinearLayout>
</ScrollView>

3
参考以上答案:
如何在滚动视图中使用相对布局。
<ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scrollView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"  >


    <RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >         
    ... ... ...

</RelativeLayout>
</ScrollView>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接