2011-07-05 4 views
1

내 애플 리케이션에서 페이지의 botton에 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는 현재 이미지를 얻고 싶습니다.

enter image description here

방법은 모든 안드로이드 장치에서 이미지 1 등 얻을 수 있습니다. 제발 친구를 도와주세요

답변

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으로 설정하면됩니다. 희망이 도움이됩니다.

관련 문제