2012-09-12 4 views
0

레이아웃을 작성했습니다. 레이아웃에는 5 개의 버튼이 있습니다.android - layout - ImageButtons 크기를 조정 하시겠습니까?

<TableLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:shrinkColumns="0,1" android:stretchColumns="*"> 


<TableRow 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:gravity="center_horizontal"> 
    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textSize="14dp" 
     android:text="Hello" 
     android:layout_span="5" 
     android:paddingTop="27dp" 
     android:paddingBottom="25dp" 
     android:textColor="#ffffff" 
     android:gravity="center" /> 
</TableRow> 

<TableRow> 

    <FrameLayout 
     android:layout_weight="0.2"> 
    </FrameLayout> 

    <FrameLayout 
     android:layout_weight="0.2"> 
     <ImageButton 
      android:id="@+id/ImageButton1" 
      android:background="@drawable/ImageButton1" 
      android:layout_width="97dp" 
      android:layout_height="90dp" 
      android:layout_gravity="center" 
      android:scaleType="center" 
      /> 
    </FrameLayout> 

    <FrameLayout 
     android:layout_weight="0.2"> 
     <ImageButton 
      android:id="@+id/ImageButton2" 
      android:layout_width="97dp" 
      android:layout_height="90dp" 
      android:background="@drawable/ImageButton2" 
      android:layout_gravity="center" 
      android:scaleType="center" />   
    </FrameLayout> 

    <FrameLayout 
     android:layout_weight="0.2"> 
     <ImageButton 
      android:id="@+id/ImageButton3" 
      android:layout_width="97dp" 
      android:layout_height="90dp" 
      android:background="@drawable/ImageButton3" 
      android:layout_gravity="center" 
      android:scaleType="center" /> 
    </FrameLayout> 

    <FrameLayout 
     android:layout_weight="0.2"> 
    </FrameLayout> 

</TableRow> 

<TableRow> 

    <FrameLayout 
     android:layout_weight="0.2"> 
    </FrameLayout> 

    <TextView 
      android:textSize="12dp" 
      android:text="Text1" 
      android:padding="3dp" 
      android:textColor="#fff" 
      android:gravity="center" /> 

    <TextView 
      android:textSize="12dp" 
      android:text="Text2" 
      android:padding="3dp" 
      android:textColor="#fff" 
      android:gravity="center" /> 

    <TextView 
      android:textSize="12dp" 
      android:text="Text3" 
      android:padding="3dp" 
      android:textColor="#fff" 
      android:gravity="center" /> 

    <FrameLayout 
     android:layout_weight="0.2"> 
    </FrameLayout> 

</TableRow> 

<View 
    android:layout_height="30dp" /> 

<TableRow> 

    <FrameLayout 
     android:layout_weight="0.2"> 
    </FrameLayout> 

    <FrameLayout 
     android:layout_weight="0.2"> 

     <ImageButton 
      android:id="@+id/ImageButton4" 
      android:layout_width="97dp" 
      android:layout_height="90dp" 
      android:background="@drawable/ImageButton4" 
      android:scaleType="center" 
      android:layout_gravity="center" /> 
    </FrameLayout> 

    <FrameLayout 
     android:layout_weight="0.2"> 
     <ImageButton 
      android:id="@+id/ImageButton5" 
      android:layout_width="97dp" 
      android:layout_height="90dp" 
      android:background="@drawable/ImageButton5 
      android:scaleType="center" 
      android:layout_gravity="center" />   
    </FrameLayout> 

    <FrameLayout 
     android:layout_weight="0.2"> 
    </FrameLayout> 

    <FrameLayout 
     android:layout_weight="0.2"> 
    </FrameLayout> 

</TableRow> 

</TableLayout> 

모든 것이 내 큰 스마트 폰에서 잘 작동합니다

http://imageshack.us/photo/my-images/607/layout.gif/ 

여기 내 TableLayout을합니다. 하지만 내 작은 스마트 폰으로 보면 맨 아래의 화면에는 더 이상 충분한 공간이 없습니다. 어떻게하면 테이블 레이아웃이 모든 것을 조정할 수 있도록 변경할 수 있습니까?

나는 이미지 버튼에 의해 여기를 주었다

작은 스마트 폰의 바닥에서하지 많은 공간이 충분한 이유가 있어요
android:layout_width="97dp" 
android:layout_height="90dp" 

. 테이블 레이아웃은 이미지 버튼의 크기를 조정해야합니다. 이미지 버튼은 정사각형 형태가 아닙니다. 그 같은 직사각형.

테이블 레이아웃은 가로 100 % 및 세로 100 %이어야합니다.

+0

은?/ –

+0

이미지 xml 파일은 고해상도에있는 이미지를 확장 . xml 파일을 만들었는데, 여기에는 상태가 있습니다. 기본값이고 누름. 이미지가 작동 중입니다. 나는 단지 규모가 필요합니다 – user1205415

+1

작은 스마트 폰에 결과의 스냅 샷을 게시 할 수 있습니까? dp를 지정하는 대신 가중치를 사용해보십시오. – Gan

답변

1

문제는 스케일링으로 인한 것인데, 화면 크기에 따라 축소되지 않는다고 생각합니다. hdpi, mdpi 및 ldpi 세 범주 모두에 대해 적절한 밀도로 새로운 드로어 블을 작성해야합니다. 당신은 당신이 두 가지 크기뿐만 아니라 화면의 밀도를 화면에 http://labs.skinkers.com/content/android_dp_px_calculator/

스케일링 따라이 도구를 사용할 수 있습니다 무엇을 필요로 밀도를 계산하기 위해

. 당신이 developer site 어떻게 안드로이드 찾을 것으로 볼 수 추가 정보를 원하시면

는 약/당김 당신이 당신의 드로어 블 hdpi에, MDPI, LDPI를 유지하는 곳 enter image description here

관련 문제