Android 安卓:底部导航栏,按钮间距相等

Android 安卓:底部导航栏,按钮间距相等,android,xml,layout,button,menu,Android,Xml,Layout,Button,Menu,嗨,我正在尝试为我的应用程序创建一个与iphone zappos应用程序类似的底部导航栏: 我目前在我的相对布局中有一个线性布局。代码如下: <LinearLayout android:layout_alignParentBottom="true" android:layout_width="wrap_content" android:layout_height="60dip" android:orientation="horizontal"> <But

嗨,我正在尝试为我的应用程序创建一个与iphone zappos应用程序类似的底部导航栏:

我目前在我的相对布局中有一个线性布局。代码如下:

    <LinearLayout 
android:layout_alignParentBottom="true" 
android:layout_width="wrap_content" 
android:layout_height="60dip"
android:orientation="horizontal">

    <Button 
    android:layout_height="fill_parent" 
    android:id="@+id/navhomebtn" 
    android:text="Home"
    android:layout_width="wrap_content" />

    <Button 
    android:layout_height="fill_parent"
    android:id="@+id/navsearchbtn" 
    android:text="Search" 
    android:layout_width="wrap_content" />

    <Button 
    android:layout_height="fill_parent" 
    android:id="@+id/navfavbtn" 
    android:text="Favorites" 
    android:layout_width="wrap_content" />
    <Button 
    android:layout_height="fill_parent" 
    android:id="@+id/navloanbtn" 
    android:text="Loans" 
    android:layout_width="wrap_content" />

</LinearLayout>

当我更改按钮以填充父项时,它们只是相互重叠,不考虑其他大小。我希望他们能填补这个空白,让不同尺寸的手机都有相似的用户界面体验。否则,我必须将它们设置为固定宽度,并使其与混合背景居中(我不想这样做)


请帮忙

尝试为每个版面宽度传递0dip。

在线性布局中使用版面权重1,在按钮中使用版面权重0dp,在按钮中使用版面权重0.25。

在按钮上使用版面权重。将所有按钮的布局权重设置为1,每个按钮将占用其父按钮宽度的1/n。

正如其他人所提到的,最简单的方法是将布局宽度设置为0dip并设置布局权重。另一种方法是使用RelativeLayout,并手动设置布局\u alignParentLeft/Right和布局\u toLeft/Rightof。

为什么要为android应用程序设计类似iphone的布局?根据我的测试,“LinearLayout中的布局权重为1”是不必要的。顺便说一句,您的解决方案有效;)