使用ScrollView包裹布局,快速将布局变为可上下滑动

来源:互联网 发布:淘宝哪个店能寄到韩国 编辑:程序博客网 时间:2024/06/10 15:45

         博主是Android开发新手,在学习过程中经常会用到ListView做成可滑动的布局,功能也很好,不过对于一些固定的不会改变的布局,使用ListView就不是那么划算了,尤其对像博主这样的新手,没有直接使用相对布局和线性布局来的直观。因而当遇到需要将一个条目固定的布局或者已经设计好的布局做成可上下滑动的效果的时候,直接使用ScrollView将自己做好的布局包裹就可以了。

实现过程如下:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scroll"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true">


... ... 自定义的布局 ... ...

<ScrollView/>


如此可直接将普通布局变为可上下拖动的布局。

0 0