当前位置:操作系统 > 安卓/Android >>

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>

 \

 


补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,