posts - 8,  comments - 25,  trackbacks - 0

          Android的應(yīng)用中有很多UI的設(shè)計(jì)都是比較固定的,比如很多應(yīng)用都會(huì)有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來實(shí)現(xiàn)比較精細(xì)的布局控制
          posted on 2011-07-10 16:33 我是風(fēng)之子 閱讀(5274) 評(píng)論(4)  編輯  收藏 所屬分類: 移動(dòng)開發(fā)相關(guān)

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

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


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

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

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          相冊(cè)

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 南靖县| 博爱县| 达日县| 泰来县| 台安县| 左贡县| 牙克石市| 长子县| 白城市| 息烽县| 策勒县| 宁海县| 枞阳县| 城口县| 阳春市| 岳阳县| 德州市| 广汉市| 讷河市| 芒康县| 新乡市| 北安市| 佛坪县| 开江县| 上栗县| 河西区| 沙坪坝区| 宜丰县| 江达县| 乐亭县| 南汇区| 类乌齐县| 无锡市| 霞浦县| 禄丰县| 宕昌县| 灵台县| 容城县| 高清| 辉南县| 新乐市|