2014年8月1日 星期五

觀察: 開發筆記: 2) 版面配置頁籤

筆記標記頁籤

為了呈現筆記資料的列表內容,設計成一個表格樣式,帶出標題列和資料列,標題列是固定位置,資料列則可以捲軸帶出更多資料內容,因此使用一個 TableLayout 元件來處理。

todo.xml
  1. <?xml version="1.0" encoding="utf-8"?>  
  2.   
  3. <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     android:gravity="top"  
  7.     >  
  8.     <TableRow>  
  9.         <TextView  
  10.             android:layout_column="0"  
  11.             android:text="@string/priority"  
  12.             android:textSize="16dip"   
  13.             android:textStyle="bold"  
  14.             android:padding="3dip"  
  15.             android:width="64px"  
  16.             />  
  17.         <TextView  
  18.             android:layout_column="1"  
  19.             android:text="@string/note_title"  
  20.             android:textSize="16dip"   
  21.             android:textStyle="bold"  
  22.             android:padding="3dip"  
  23.             />  
  24.     </TableRow>  
  25.   
  26.     <View  
  27.         android:layout_height="1px"  
  28.         android:background="#FFff0000" />  
  29.   
  30.     <ScrollView  
  31.         android:layout_width="fill_parent"  
  32.         android:layout_height="wrap_content"  
  33.         android:gravity="top"  
  34.         >  
  35.         <TableLayout   
  36.             android:id="@+id/table"  
  37.             android:layout_width="fill_parent"  
  38.             android:layout_height="fill_parent"  
  39.             android:gravity="top"  
  40.             >  
  41.         </TableLayout>  
  42.     </ScrollView>  
  43. </TableLayout>  



垃圾桶頁籤

跟筆記資料頁籤類似,只是下方多了一列含有兩個固定位置的刪除按鈕。

done.xml
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.     >  
  6.     <TableLayout  
  7.         android:layout_width="fill_parent"  
  8.         android:layout_height="wrap_content"  
  9.         android:gravity="top"  
  10.         >  
  11.   
  12.         <TableRow>  
  13.             <TextView  
  14.                 android:layout_column="0"  
  15.                 android:text="@string/delete"  
  16.                 android:textSize="16dip"   
  17.                 android:textStyle="bold"  
  18.                 android:padding="3dip"  
  19.                 android:width="64px"  
  20.                 />  
  21.             <TextView  
  22.                 android:layout_column="1"  
  23.                 android:text="@string/note_title"  
  24.                 android:textSize="16dip"   
  25.                 android:textStyle="bold"  
  26.                 android:padding="3dip"  
  27.                 />  
  28.         </TableRow>  
  29.       
  30.       
  31.         <View  
  32.             android:layout_height="1px"  
  33.             android:background="#FFffff00" />  
  34.       
  35.         <ScrollView  
  36.             android:layout_width="fill_parent"  
  37.             android:layout_height="wrap_content"  
  38.             android:gravity="top"  
  39.             >  
  40.             <TableLayout   
  41.                 android:id="@+id/donetable"  
  42.                 android:layout_width="fill_parent"  
  43.                 android:layout_height="fill_parent"  
  44.                 android:gravity="top"  
  45.                 >  
  46.             </TableLayout>  
  47.         </ScrollView>  
  48.       
  49.     </TableLayout>  
  50.     <LinearLayout  
  51.         android:layout_width="fill_parent"  
  52.         android:layout_height="wrap_content"  
  53.         android:orientation="horizontal"  
  54.         android:layout_alignParentBottom="true"  
  55.         android:gravity="center_horizontal"  
  56.         android:weightSum="2"  
  57.         >  
  58.         <Button  
  59.             android:id="@+id/delchecked"  
  60.             android:layout_width="wrap_content"  
  61.             android:layout_height="wrap_content"  
  62.             android:text="刪除已選"  
  63.             android:layout_weight="1"  
  64.             />  
  65.         <Button  
  66.             android:id="@+id/delall"  
  67.             android:layout_width="wrap_content"  
  68.             android:layout_height="wrap_content"  
  69.             android:text="全部刪除"  
  70.             android:layout_weight="1"  
  71.             />  
  72.     </LinearLayout>  
  73. </RelativeLayout>  



組態設定頁籤

含有組態項目文字及一個下拉式按鈕,外層使用 RelativeLayout。

config.xml
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     >  
  7.   
  8.     <TextView  
  9.         android:layout_width="fill_parent"  
  10.         android:layout_height="wrap_content"  
  11.         android:background="#ffff00"  
  12.         android:textColor="#ff0000"  
  13.         android:textSize="24px"  
  14.         android:textStyle="bold"  
  15.         android:text="@string/setting"  
  16.         />  
  17.           
  18.     <RelativeLayout  
  19.         android:layout_marginTop="12px"  
  20.         android:layout_width="fill_parent"  
  21.         android:layout_height="wrap_content"  
  22.         >  
  23.         <TextView  
  24.             android:layout_alignParentLeft="true"  
  25.             android:layout_width="wrap_content"  
  26.             android:layout_height="wrap_content"  
  27.             android:text="@string/default_priority"  
  28.             android:textSize="24px"  
  29.             />  
  30.         <Spinner  
  31.             android:id="@+id/default_priority"  
  32.             android:layout_alignParentRight="true"  
  33.             android:layout_width="wrap_content"  
  34.             android:layout_height="wrap_content"  
  35.             android:prompt="@string/default_priority"  
  36.             />  
  37.     </RelativeLayout>    
  38.       
  39. </LinearLayout>  
參考資料:http://ithelp.ithome.com.tw/question/10138769

沒有留言:

張貼留言