posts - 8,  comments - 25,  trackbacks - 0

          Android的應(yīng)用中有很多UI的設(shè)計都是比較固定的,比如很多應(yīng)用都會有titlebar和tabbar。我這里就將自己工作過程中碰到的各種比較固定的UI組件的制作方法寫出來。
          titlebar(標(biāo)題欄)的應(yīng)用尤為廣泛,主要起到提示和導(dǎo)航的作用,組件里面涉及到的控件有ImageView和TextView(這里并不唯一,視你制作方法而定)。下面就來介紹我的做法,先貼上main.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     android:background="@drawable/background">
           7     
           8     <RelativeLayout android:layout_width="fill_parent"
           9         android:layout_height="wrap_content"
          10         android:background="@drawable/toolbar_background" >
          11         
          12         <RelativeLayout android:id="@+id/toolbar_left"
          13             android:layout_width="wrap_content" 
          14             android:layout_height="wrap_content"
          15             android:layout_alignParentLeft="true"
          16             android:layout_centerVertical="true"
          17             android:layout_marginLeft="10dip"
          18             android:clickable="true">
          19             <ImageView android:id="@+id/toolbar_left_image"
          20                 style="@style/toolbar_left_button_image"/>
          21             <TextView android:id="@+id/toolbar_left_text"
          22                 android:text="@string/toolbar_return" 
          23                 android:layout_alignTop="@id/toolbar_left_image"
          24                 android:layout_alignLeft="@id/toolbar_left_image"
          25                 style="@style/toolbar_left_button_text" />
          26         </RelativeLayout>
          27         
          28         <RelativeLayout android:layout_width="wrap_content"
          29             android:layout_height="wrap_content"
          30             android:layout_centerInParent="true">
          31             <TextView android:layout_width="wrap_content"
          32                 android:layout_height="wrap_content"
          33                 android:text="@string/toolbar_everydaytip"
          34                 style="@style/toolbar_text" />
          35         </RelativeLayout>
          36         
          37         <RelativeLayout android:id="@+id/toolbar_right"
          38             android:layout_width="wrap_content" 
          39             android:layout_height="wrap_content"
          40             android:layout_alignParentRight="true"
          41             android:layout_centerVertical="true"
          42             android:layout_marginRight="10dip"
          43             android:clickable="true">
          44             <ImageView android:id="@+id/toolbar_right_image"
          45                 style="@style/toolbar_right_button_image" />
          46             <TextView android:id="@+id/toolbar_right_text"
          47                 android:text="@string/toolbar_index" 
          48                 android:layout_alignTop="@id/toolbar_right_image"
          49                 android:layout_alignLeft="@id/toolbar_right_image"
          50                 style="@style/toolbar_right_button_text" />
          51         </RelativeLayout>
          52         
          53     </RelativeLayout>
          54
          55 </LinearLayout>
          附圖如下:

          這里主要用到了RelativeLayout來實現(xiàn)比較精細(xì)的布局控制
          posted on 2011-07-10 16:33 我是風(fēng)之子 閱讀(5276) 評論(4)  編輯  收藏 所屬分類: 移動開發(fā)相關(guān)

          FeedBack:
          # re: Android常用UI之titlebar制作
          2011-07-10 23:31 | 步步為營
          很實用,這設(shè)計最初是iPhone用戶的習(xí)慣 :)  回復(fù)  更多評論
            
          # re: Android常用UI之titlebar制作
          2011-07-11 09:11 | 爆爆藍(lán)
          在android 里面完全沒必要照搬ipone的設(shè)計,因為androi有實體的返回鍵和主頁鍵  回復(fù)  更多評論
            
          # re: Android常用UI之titlebar制作
          2011-07-11 11:39 | 我是風(fēng)之子
          @爆爆藍(lán)
          我這里的返回鍵和主頁鍵只是個例子,實際只是個跳轉(zhuǎn)按鈕;
          不過android的主頁鍵會離開程序的吧  回復(fù)  更多評論
            
          # re: Android常用UI之titlebar制作
          2013-09-24 21:42 | 4332weizi
          能不能把style也發(fā)出來啊……  回復(fù)  更多評論
            

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           

          <2011年7月>
          262728293012
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          相冊

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 柞水县| 古浪县| 瑞安市| 敦化市| 裕民县| 周口市| 五大连池市| 云安县| 古交市| 宾阳县| 小金县| 达拉特旗| 奉新县| 施秉县| 永寿县| 宁陕县| 南开区| 奇台县| 丘北县| 岑溪市| 汨罗市| 太康县| 鲁山县| 吉水县| 喀喇| 九龙坡区| 高青县| 石柱| 宜章县| 锡林郭勒盟| 长泰县| 瑞丽市| 铅山县| 洛隆县| 佛学| 阿拉善盟| 虞城县| 乐至县| 民勤县| 清原| 门源|