2012-06-30 2 views
0

Android 개발이 처음입니다.
두 개의 테이블 행에 버튼을 몇 개 설정하고 싶습니다. 어떤 도움
테이블 셀이 TableLayout에서 모든 화면 높이를 사용하게하려면 어떻게해야합니까?

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/TableLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 


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

     <Button 
      android:id="@+id/button1" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Button" /> 

     <Button 
      android:id="@+id/button2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Button" /> 

     <Button 
      android:id="@+id/button3" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Button" /> 
    </TableRow> 


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

    </TableRow> 

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

</TableLayout> 

감사 : 그러나 현재 그들은 다음은이 활동의 ​​레이아웃에 대한 XML은 그
의 작은 부분을 사용!

답변

1

시도는 안드로이드 사용 : ....

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

이 같은이

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/TableLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 


    <TableRow 
     android:id="@+id/tableRow1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="#ffff0000"> 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 
      android:text="Button" /> 

     <Button 
      android:id="@+id/button2" 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 
      android:text="Button" /> 

     <Button 
      android:id="@+id/button3" 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 
      android:text="Button" /> 
    </TableRow> 


    <TableRow 
     android:id="@+id/tableRow2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
      android:background="#ff00ff00"> 

    </TableRow> 

    <TableRow 
     android:id="@+id/tableRow3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
      android:background="#ff00ff"> 
    </TableRow> 

</TableLayout> 

enter image description here

+0

로 다음을 수행합니다. –

+0

여러분의 노력에 감사 드리며 각 버튼 layout_height = "0dp"에 대해 아마 설정해야합니다. 그러면 행이 3 개인 경우 화면 높이의 1/3을 차지하게됩니다. –

+0

미안하지만, 3 열 모두가 화면 크기를 채울 수 있기를 원하십니까? –

0

그것의 참조 = "1"테이블 행에에 layout_weight를

  1. 둘 중 하나 Eclipse에서 XML 속성을 편집하는 GUI 도구로 이동하여 레이아웃 속성 layout weight to 1을 설정합니다.

    OR은 XML 페이지를 고토하고,이 help.They 여전히 전체 화면 높이를 차지하지 않았다 테이블 행 android:layout_weight="1" android:layout_width="wrap_content"android:layout_height="wrap_content"

+0

레이아웃의 layout_width 및 layout_height는 어떻게됩니까? 그들을 다른 것으로 설정하거나 fill_parent로 유지해야합니까? –

+0

android : layout_width = "wrap_content"android : layout_height = "wrap_content"나는 당신이 그것을 구현할 것임을 분명히 생각하면서 그들을 언급하지 않았다 ... 미안해. –

관련 문제