2010-04-25 155 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"