ScrollView,使用v4包下进行和新控件使用

来源:互联网 发布:二手交易管理系统源码 编辑:程序博客网 时间:2024/05/23 12:50

*

ScrollView里只能包含一个子控件,多余一个就会报错*

需要放多个View的集合,所以用一个布局文件包裹。

ScrollView里的高度无效。

 <ScrollView      android:layout_width="match_parent"      android:layout_height="match_parent">      <LinearLayout          android:layout_width="match_parent"          android:layout_height="match_parent"          android:orientation="vertical"          >        <ImageView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:src="@mipmap/ic_launcher"            />     </LinearLayout>   </ScrollView>

此时虽然高度充满但是只有图片那么大

这里写图片描述

重点内容

**

如果要设置高度的大小 需要在LinearLayout里添加**

这里写图片描述

滚动条的属性

<ScrollView      android:layout_width="match_parent"      android:layout_height="match_parent"      android:scrollbars="none" //设置不显示滚动条      >

设置滚动条的样式。

 <ScrollView      android:layout_width="match_parent"      android:layout_height="match_parent"      android:scrollbarTrackVertical="@drawable/scrollbar_bg"  //滚动条滚动的背景样式      android:scrollbarThumbVertical="@drawable/scrollbar"    //滚动块的样式      android:scrollbarSize="20dp"//滚动条大小      >

这里写图片描述

v4包下的ScrollView

<android.support.v4.widget.NestedScrollView      android:layout_width="match_parent"      android:layout_height="match_parent"      android:scrollbarTrackVertical="@drawable/scrollbar_bg"      android:scrollbarThumbVertical="@drawable/scrollbar"      android:scrollbarSize="20dp"      >
0 0
原创粉丝点击