android应用程序中图像按钮的UI存在问题

android应用程序中图像按钮的UI存在问题,android,user-interface,android-relativelayout,Android,User Interface,Android Relativelayout,在我的应用程序中,我在页面底部放置了4个图像按钮。但根据我的布局,每个设备的图像看起来都不一样。我希望所有设备中的图像都相同 以下是“我的图像”按钮的布局 <LinearLayout android:layout_height="wrap_content" android:id="@+id/tabLayout" android:layout_width="match_parent" android:background="@drawable/tab_bar" an

在我的应用程序中,我在页面底部放置了4个图像按钮。但根据我的布局,每个设备的图像看起来都不一样。我希望所有设备中的图像都相同

以下是“我的图像”按钮的布局

 <LinearLayout android:layout_height="wrap_content" android:id="@+id/tabLayout" android:layout_width="match_parent" 
           android:background="@drawable/tab_bar" android:orientation="horizontal" android:layout_weight="0.1">
    <RelativeLayout android:id="@+id/relativeLayout1" android:layout_height="match_parent" android:layout_width="match_parent">
        <ImageButton android:layout_marginLeft="35dip" android:layout_height="wrap_content" android:id="@+id/homeBtn" android:background="@drawable/home"   android:layout_width="wrap_content" android:layout_gravity="center"></ImageButton>
        <ImageButton android:layout_marginLeft="35dip" android:layout_toRightOf="@+id/homeBtn" android:layout_height="wrap_content" android:id="@+id/addBtn"  android:background="@drawable/add"    android:layout_width="wrap_content" android:layout_gravity="center"></ImageButton>
        <ImageButton android:layout_marginLeft="35dip" android:layout_toRightOf="@+id/addBtn" android:layout_height="wrap_content" android:id="@+id/srchBtn" android:background="@drawable/search" android:layout_width="wrap_content" android:layout_gravity="center"></ImageButton>
        <ImageButton android:layout_marginLeft="35dip" android:layout_toRightOf="@+id/srchBtn" android:layout_height="wrap_content" android:id="@+id/helpBtn" android:background="@drawable/help"   android:layout_width="wrap_content" android:layout_gravity="center"></ImageButton>          
    </RelativeLayout>                               

以下是我的布局图。我希望我的布局如图1所示,而图2是我当前得到的图像


如何在所有android设备中获得与图像1一样的效果。朋友们,请帮帮我,我建议你们使用线性布局。使用它可以更轻松地水平对齐按钮。只需将他们的
android:layout\u width
属性设置为
fill\u parent
,将
android:layout\u weight
设置为
1
。希望这有帮助。

我建议您使用线性布局。使用它可以更轻松地水平对齐按钮。只需将他们的
android:layout\u width
属性设置为
fill\u parent
,将
android:layout\u weight
设置为
1
。希望这能有所帮助。

正如其他人提到的那样,最好使用线性布局,但您还需要做的是为线性布局提供填充,我猜5dp应该看起来不错

下面是它的外观:

这是相同的代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:orientation="horizontal"
    android:padding="5dp" android:background="#a0a0a0"
    android:layout_height="wrap_content">
    <Button android:text="Button" android:id="@+id/button2"
        android:layout_width="0dp" android:layout_weight="1"
        android:layout_height="wrap_content"></Button>
    <Button android:text="Button" android:id="@+id/button1"
        android:layout_width="0dp" android:layout_weight="1"
        android:layout_height="wrap_content"></Button>
    <Button android:text="Button" android:id="@+id/button3"
        android:layout_width="0dp" android:layout_weight="1"
        android:layout_height="wrap_content"></Button>
    <Button android:text="Button" android:id="@+id/button4"
        android:layout_width="0dp" android:layout_weight="1"
        android:layout_height="wrap_content"></Button>

</LinearLayout>

正如其他人提到的,最好使用线性布局,但您还需要做的是为线性布局提供填充,我猜5dp应该看起来不错

下面是它的外观:

这是相同的代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:orientation="horizontal"
    android:padding="5dp" android:background="#a0a0a0"
    android:layout_height="wrap_content">
    <Button android:text="Button" android:id="@+id/button2"
        android:layout_width="0dp" android:layout_weight="1"
        android:layout_height="wrap_content"></Button>
    <Button android:text="Button" android:id="@+id/button1"
        android:layout_width="0dp" android:layout_weight="1"
        android:layout_height="wrap_content"></Button>
    <Button android:text="Button" android:id="@+id/button3"
        android:layout_width="0dp" android:layout_weight="1"
        android:layout_height="wrap_content"></Button>
    <Button android:text="Button" android:id="@+id/button4"
        android:layout_width="0dp" android:layout_weight="1"
        android:layout_height="wrap_content"></Button>

</LinearLayout>