2010-04-25 59 views
0

我有我的main.xml中有一個列表視圖的線性佈局。現在我想在listview下創建一個底部欄。Android Bottombar有兩個按鈕具有不同的背景和兩個按鈕的共同背景

Bottombar有一個背景圖像和兩個按鈕與他們各自的背景圖像。我想把這兩個按鈕放在共同的背景圖像上。

我已經讀過,這可以使用FrameLayout來實現。但是因爲我在main.xml中使用LinearLayout作爲基礎佈局,有沒有辦法使用linearlayout進行這種設計?

+0

,可以考慮添加一些截圖來解釋你提出的設計更好。無論如何,「FrameLayout」對你的情況都沒用。 – CommonsWare 2010-04-25 11:19:55

回答

3

這是您想要簡單地使用linearlayout並使用加權來獲得底欄顯示的示例。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
<ListView 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_weight="1" 
android:background="#FF0000FF" 
/> 
<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="100dip" 
android:orientation="horizontal" 
android:layout_weight="1" 
android:background="#FF00FF00" 
> 
    <Button 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="1" 
    android:text="Button 1" 
    /> 
    <Button 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="1" 
    android:text="Button 2" 
    />  
</LinearLayout> 
</LinearLayout> 

Linearlayout example view http://web11.twitpic.com/img/91422474-946af96885721237646940af1c9328a9.4bd47fa4-full.png

而且你可以通過改變純色我已經展示了喜歡的東西拿到背景:

android:background="@drawable/background.png"