標籤:des android style blog http ar io color 使用
1. activity_maim.xml
[html] view plaincopy
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
-
- <ScrollView
- android:id="@+id/view1"
- android:layout_width="100dip"
- android:layout_height="120dip"
- android:background="@android:color/white"
- android:padding="8dip"
- android:scrollbarStyle="insideOverlay" >
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="@android:color/darker_gray"
- android:text="scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text"
- android:textColor="#ffffff" />
- </ScrollView>
-
- <ScrollView
- android:id="@+id/view2"
- android:layout_width="100dip"
- android:layout_height="120dip"
- android:background="@android:color/white"
- android:padding="8dip"
- android:scrollbarStyle="insideInset" >
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="@android:color/darker_gray"
- android:text="scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text"
- android:textColor="#ffffff" />
- </ScrollView>
-
- <ScrollView
- android:id="@+id/view3"
- android:layout_width="100dip"
- android:layout_height="120dip"
- android:background="@android:color/white"
- android:padding="8dip"
- android:scrollbarStyle="outsideOverlay" >
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="@android:color/darker_gray"
- android:text="scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text"
- android:textColor="#ffffff" />
- </ScrollView>
-
- <ScrollView
- android:id="@+id/view4"
- android:layout_width="100dip"
- android:layout_height="120dip"
- android:background="@android:color/white"
- android:padding="8dip"
- android:scrollbarStyle="outsideInset" >
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="@android:color/darker_gray"
- android:text="scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text"
- android:textColor="#ffffff" />
- </ScrollView>
-
- </LinearLayout>
2. 運行結果:
insideInset、insideOverlay、outsideInset、outsideOverlay分別對應左邊解釋!
3.android:scrollbarStyle可以定義捲軸的樣式和位置,用於Listview、scrollview等滾動view,可選值有insideOverlay、insideInset、outsideOverlay、outsideInset四種。
其中inside和outside分別表示是否在view的padding地區內,overlay和inset表示覆蓋在view上或是插在view後面,所以四種值分別表示:
insideOverlay:預設值,表示在padding地區內並且覆蓋在view上
insideInset:表示在padding地區內並且插入在view後面
outsideOverlay:表示在padding地區外並且覆蓋在view上
outsideInset:表示在padding地區外並且插入在view後面4.自訂scrollbar
android:scrollbars="vertical"android:fadeScrollbars="true" //true scrollbar不滾動隱藏android:scrollbarThumbVertical="@drawable/scrollbar" //自訂scrollbar
android:scrollbarTrackHorizontal="@drawable/scrollbar_bg" //自訂scrollbar背景android:scrollbarStyle="outsideInset" //scrollbar風格
- 上一篇Android Fragments 詳細使用
- 下一篇Android自訂屬性時format選項( <attr format="reference" name="background" /> )
android:scrollbar的一些屬性