Android ApiDemos示例解析(190):Views->ScrollBars->3. Style

本例介绍了ScrollView 的几种风格,android:scrollbarStyle 用来定义滚动条的风格和位置,滚动条位置可以为”overlaid”或是”inset”,当使用”inset” 风格时,滚动条添加到View的Padding区域。滚动条可以显示在View的Padding区域内或是在View的边缘。

scrollbarStyle 有如下几种风格:

  • insideOverlay   inside the padding and overlaid
  • insideInset        inside the padding and inset
  • outsideOverlay   Edge of the view and overlaid
  • outsideInset       Eged of the view and inset

本例的XML

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

<LinearLayout
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:orientation=”horizontal”>

<ScrollView
android:layout_width=”100dip”
android:layout_height=”120dip”
android:background=”#FF0000″
>
<LinearLayout
android:orientation=”vertical”
android:layout_width=”match_parent”
android:layout_height=”match_parent”>

<TextView
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/scrollbar_2_text” />

<TextView
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/scrollbar_2_text” />
</LinearLayout>
</ScrollView>

<ScrollView
android:layout_width=”100dip”
android:layout_height=”120dip”
android:background=”#00FF00″
android:paddingRight=”12dip”>

<TextView
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/scrollbar_3_text”
android:textColor=”#000000″
android:background=”#60AA60″ />
</ScrollView>

<ScrollView
android:id=”@+id/view3″
android:layout_width=”100dip”
android:layout_height=”120dip”
android:background=”@android:drawable/edit_text”>

<TextView
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:textColor=”#000000″
android:text=”@string/scrollbar_3_text” />
</ScrollView>
</LinearLayout>

<LinearLayout
android:layout_width=”match_parent”
android:layout_height=”wrap_content”>
<ScrollView
android:id=”@+id/view4″
android:layout_width=”100dip”
android:layout_height=”120dip”
android:scrollbarStyle=”outsideOverlay”
android:background=”@android:drawable/edit_text”>

<TextView
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:textColor=”#000000″
android:text=”@string/scrollbar_3_text” />
</ScrollView>
<ScrollView
android:id=”@+id/view5″
android:layout_width=”100dip”
android:layout_height=”120dip”
android:scrollbarStyle=”outsideInset”
android:background=”@android:drawable/edit_text”
>
<TextView
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:textColor=”#000000″
android:text=”@string/scrollbar_3_text” />
</ScrollView>
</LinearLayout>
</LinearLayout>

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值