您的位置:首页 > 移动开发 > Android开发

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

2012-10-13 22:47 531 查看
本例介绍了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>



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: