1. 程式人生 > >簡單實現Android頂部工具欄和底部工具欄

簡單實現Android頂部工具欄和底部工具欄

直接上圖,有圖有真相。

這兩個工具欄全是用佈局來實現的。

Android

底部工具欄佈局程式碼:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout
    
="http://schemas.android.com/apk/res/android"
    android:background
="@drawable/bottom"
    android:layout_width
="fill_parent"
    android:layout_height
="wrap_content"><TextView
        
android:id

="@+id/edit"
        android:text
="測試"
        android:gravity
="center_horizontal"
        android:drawableTop
="@drawable/ic_dialog_alert"
        android:layout_alignParentLeft
="true"
        android:layout_width
="80dip"
        android:layout_height
="wrap_content"></TextView><TextView
        
android:id="@+id/menu2"
        android:text
="測試"
        android:gravity
="center_horizontal"
        android:drawableTop
="@drawable/ic_dialog_dialer"
        android:layout_toRightOf
="@id/edit"    
        android:layout_width
="80dip"
        android:layout_height
="wrap_content"></TextView><
TextView
        
android:id="@+id/effect"
        android:text
="測試"
        android:gravity
="center_horizontal"
        android:drawableTop
="@drawable/ic_dialog_email"
        android:layout_toRightOf
="@id/menu2"
        android:layout_width
="80dip"
        android:layout_height
="wrap_content"></TextView><TextView
        
android:id="@+id/menu3"
        android:text
="測試"
        android:gravity
="center_horizontal"
        android:drawableTop
="@drawable/ic_dialog_info"
        android:layout_toRightOf
="@id/effect"
        android:layout_width
="80dip"
        android:layout_height
="wrap_content"></TextView></RelativeLayout>