2011-07-05 14 views
1

私のアプリでは、ページのボタンに4つの画像ボタンを配置しています。しかし、私のレイアウトによれば、イメージは各デバイスで異なって見えます。すべてのデバイスでイメージが同じになるようにします。続きアンドロイドアプリの画像ボタンのUIに問題がある

は私のレイアウトの画像であり、後の私のイメージボタン

<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>        

のレイアウトです。私は自分のレイアウトをimage1と同じにしたい、image2は現在私が得ているイメージです。すべてのAndroidデバイスでの画像1等を取得する方法

enter image description here

。私の友人を助けてください。

答えて

1

他の人が最高のことを言いましたが、線形レイアウトを使用しますが、線形レイアウトにパディングを提供することも必要です.5dpがよく見えるはずです。ここで

は、それがどのように見えるかです:

enter image description here

そして、ここでは同じ

<?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> 
のコードです
0

私はあなたにLinearLayoutを使うことをお勧めします。ボタンを使用してボタンを水平に整列する方がはるかに簡単です。 android:layout_widthプロパティをfill_parentandroid:layout_weightから1に設定するだけです。お役に立てれば。

関連する問題