Android(java)學習筆記110:ScrollView用法

來源:互聯網
上載者:User

標籤:

理論部分

1、ScrollView和HorizontalScrollView是為控制項或者布局添加捲軸

2、上述兩個控制項只能有一個孩子,但是它並不是傳統意義上的容器

3、上述兩個控制項可以互相嵌套

4、捲軸的位置現在的實驗結果是:可以由layout_width和layout_height設定

5、ScrollView用於設定垂直捲軸,HorizontalScrollView用於設定水平捲軸:需要注意的是,有一個屬性是    scrollbars 可以設定捲軸的方向:但是ScrollView設定成horizontal是和設定成none是效果同,HorizontalScrollView設定成vertical和none的效果同。

代碼實踐:

 1 <?xml version="1.0" encoding="utf-8"?> 2 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 3     android:id="@+id/mScrollView" 4     android:layout_width="fill_parent" 5     android:layout_height="wrap_content" 6     android:scrollbars="vertical" > 7  8     <LinearLayout 9         android:layout_width="fill_parent"10         android:layout_height="wrap_content"11         android:orientation="vertical" >12 13         <LinearLayout14             android:layout_width="fill_parent"15             android:layout_height="fill_parent"16             android:orientation="horizontal" >17 18             <Button19                 android:id="@+id/openNetCard"20                 android:layout_width="wrap_content"21                 android:layout_height="wrap_content"22                 android:layout_weight="1"23                 android:text="開啟無線網卡" />24 25             <Button26                 android:id="@+id/closeNetCard"27                 android:layout_width="wrap_content"28                 android:layout_height="wrap_content"29                 android:layout_weight="1"30                 android:text="關閉無線網卡" />31 32             <Button33                 android:id="@+id/checkNetCardState"34                 android:layout_width="wrap_content"35                 android:layout_height="wrap_content"36                 android:layout_weight="1"37                 android:text="檢查網卡狀態" />38         </LinearLayout>39 40         <LinearLayout41             android:layout_width="fill_parent"42             android:layout_height="fill_parent"43             android:orientation="horizontal" >44 45             <Button46                 android:id="@+id/scan"47                 android:layout_width="wrap_content"48                 android:layout_height="wrap_content"49                 android:layout_weight="1"50                 android:text="掃描網路" />51 52             <Button53                 android:id="@+id/getScanResult"54                 android:layout_width="wrap_content"55                 android:layout_height="wrap_content"56                 android:layout_weight="1"57                 android:text="掃描結果" />58         </LinearLayout>59 60         <LinearLayout61             android:layout_width="fill_parent"62             android:layout_height="fill_parent"63             android:orientation="horizontal" >64 65             <Button66                 android:id="@+id/connect"67                 android:layout_width="wrap_content"68                 android:layout_height="wrap_content"69                 android:layout_weight="1"70                 android:text="串連Wifi" />71 72             <Button73                 android:id="@+id/disconnect"74                 android:layout_width="wrap_content"75                 android:layout_height="wrap_content"76                 android:layout_weight="1"77                 android:text="斷開Wifi" />78 79             <Button80                 android:id="@+id/checkNetWorkState"81                 android:layout_width="wrap_content"82                 android:layout_height="wrap_content"83                 android:layout_weight="1"84                 android:text="Wifi串連狀態" />85         </LinearLayout>86 87         <TextView88             android:id="@+id/scanResult"89             android:layout_width="fill_parent"90             android:layout_height="wrap_content" />91     </LinearLayout>92 93 </ScrollView>

布局圖如下:

 

……

public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
   }
……

 

Android(java)學習筆記110:ScrollView用法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.