2014-05-12 8 views
0

타일이 적용된 앱을 사용하고 있습니다. 내부에 2 개의 테이블 행이있는 테이블 레이아웃을 사용하고 있기 때문에 문제가 있습니다. 그러나 첫 번째 행을 약간 축소해야하지만 이미 패딩 및 여백을 사용하려고했습니다 (paddingBottom & android : layout_marginBottom) 그러나 나는 내가하고 싶은 것을하기 위해 첫 줄을 줄이는 방법을 얻지 못한다. 나는 내가하고 싶은 것을 더 잘 설명하는 2 개의 이미지를 첨부했다. 첫 번째 것은 내가 여기에 넣은 코드로 얻은 것이다. 두 번째는 내가하고 싶은 것을 더 잘 설명합니다.테이블 행 높이 변경

응답 성있는 UI를 수행해야하므로 고정 된 Android : layout_height를 사용하지 않아야합니다.

This is what I want to do

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white" > 

    <TableRow 
     android:id="@+id/tableRow1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_margin="2dp" 
      android:layout_weight="1" 
      android:background="@drawable/camera" 
      android:gravity="top|center_horizontal" 
      android:onClick="camera" /> 

     <Button 
      android:id="@+id/button2" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_margin="2dp" 
      android:layout_weight="1" 
      android:background="@drawable/gallery" 
      android:gravity="top|center_horizontal" 
      android:onClick="gallery" /> 
    </TableRow> 

    <TableRow 
     android:id="@+id/tableRow2" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="1" > 

     <Button 
      android:id="@+id/button3" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_margin="2dp" 
      android:layout_weight="1" 
      android:background="@drawable/bank_bbva" 
      android:gravity="top" /> 
    </TableRow> 
</TableLayout> 

답변

0

왜이 레이아웃을 시도 :

This is what I have

이 내가하고 싶은 것입니다 :

이 내가 가진 무엇인가?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

<Button 
     android:id="@+id/button1" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_margin="2dp" 
     android:layout_weight="0.5" 
     android:background="@drawable/camera" 
     android:gravity="top|center_horizontal" 
     android:onClick="camera" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_margin="2dp" 
     android:layout_weight="0.5" 
     android:background="@drawable/gallery" 
     android:gravity="top|center_horizontal" 
     android:onClick="gallery" /> 
</LinearLayout> 

<Button 
     android:id="@+id/button3" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_margin="2dp" 
     android:layout_weight="1" 
     android:background="@drawable/bank_bbva" 
     android:gravity="top" /> 

</LinearLayout> 
0
// try this way,hope this will help you... 

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white" > 

    <TableRow 
     android:id="@+id/tableRow1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="5dp"> 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="@drawable/camera" 
      android:onClick="camera" /> 

     <Button 
      android:id="@+id/button2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_weight="1" 
      android:background="@drawable/gallery" 
      android:onClick="gallery" /> 
    </TableRow> 

    <TableRow 
     android:id="@+id/tableRow2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <Button 
      android:id="@+id/button3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/bank_bbva"/> 
    </TableRow> 
</TableLayout>