android:scrollbar的一些屬性

來源:互聯網
上載者:User

標籤:des   android   style   blog   http   ar   io   color   使用   

1. activity_maim.xml [html] view plaincopy 
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     android:layout_width="fill_parent"  
  3.     android:layout_height="fill_parent"  
  4.     android:orientation="vertical" >  
  5.   
  6.     <ScrollView  
  7.         android:id="@+id/view1"  
  8.         android:layout_width="100dip"  
  9.         android:layout_height="120dip"  
  10.         android:background="@android:color/white"  
  11.         android:padding="8dip"  
  12.         android:scrollbarStyle="insideOverlay" >  
  13.   
  14.         <TextView  
  15.             android:layout_width="fill_parent"  
  16.             android:layout_height="wrap_content"  
  17.             android:background="@android:color/darker_gray"  
  18.             android:text="scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text"  
  19.             android:textColor="#ffffff" />  
  20.     </ScrollView>  
  21.   
  22.     <ScrollView  
  23.         android:id="@+id/view2"  
  24.         android:layout_width="100dip"  
  25.         android:layout_height="120dip"  
  26.         android:background="@android:color/white"  
  27.         android:padding="8dip"  
  28.         android:scrollbarStyle="insideInset" >  
  29.   
  30.         <TextView  
  31.             android:layout_width="fill_parent"  
  32.             android:layout_height="wrap_content"  
  33.             android:background="@android:color/darker_gray"  
  34.             android:text="scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text"  
  35.             android:textColor="#ffffff" />  
  36.     </ScrollView>  
  37.   
  38.     <ScrollView  
  39.         android:id="@+id/view3"  
  40.         android:layout_width="100dip"  
  41.         android:layout_height="120dip"  
  42.         android:background="@android:color/white"  
  43.         android:padding="8dip"  
  44.         android:scrollbarStyle="outsideOverlay" >  
  45.   
  46.         <TextView  
  47.             android:layout_width="fill_parent"  
  48.             android:layout_height="wrap_content"  
  49.             android:background="@android:color/darker_gray"  
  50.             android:text="scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text"  
  51.             android:textColor="#ffffff" />  
  52.     </ScrollView>  
  53.   
  54.     <ScrollView  
  55.         android:id="@+id/view4"  
  56.         android:layout_width="100dip"  
  57.         android:layout_height="120dip"  
  58.         android:background="@android:color/white"  
  59.         android:padding="8dip"  
  60.         android:scrollbarStyle="outsideInset" >  
  61.   
  62.         <TextView  
  63.             android:layout_width="fill_parent"  
  64.             android:layout_height="wrap_content"  
  65.             android:background="@android:color/darker_gray"  
  66.             android:text="scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text scroll_text"  
  67.             android:textColor="#ffffff" />  
  68.     </ScrollView>  
  69.   
  70. </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的一些屬性

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.