2012-04-30 4 views
2

enter image description here 테이블 레이아웃을 사용하고 있습니다. 내가 원하는 것이 전체 화면의 높이를 커버하도록 화면의 왼쪽에있는 세로 레이아웃 (테이블 레이아웃)에 표시된 아이콘의 간격을 동일하게 배치하는 것입니다. layout_weight = "1"과 같은 다른 방법을 시도해 보았습니다. 이미지 너비를 0dp로 설정 한 다음 무게를 설정했습니다 ... 그러나 그 중 아무 것도 도움이되지 않았습니다 .....테이블 레이아웃 간격 문제

여기는 XML입니다 ...

<TableLayout 
       android:id="@+id/tableLayout1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 

       android:layout_marginTop="50dp" > 

       <TableRow 
        android:layout_weight="1" 
       > 
        <Button 
       android:id="@+id/button1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"          
       android:background="@drawable/XXX" /> 
       </TableRow> 

       <TableRow 
        android:layout_weight="1" 
        > 
       <TextView 
       android:id="@+id/textView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Desserts" 
       /> 
        </TableRow> 

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

       android:background="@drawable/sraberrydrink" /> 
        </TableRow> 

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

       android:text="Drinks" 
       android:textColor="#000000"    
       android:textSize="10dp" /> 
        </TableRow> 

        <TableRow 
        android:layout_weight="1" 
        > 

        <Button 
       android:id="@+id/button3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 

       android:background="@drawable/newsoups" /> 
        </TableRow> 
       <TableRow 
        android:layout_weight="1" 
        > 
        <TextView 
       android:id="@+id/textView3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="45dp" 
       android:text="Starters" 
       android:textColor="#000000" 
       android:textSize="10dp" /> 

        </TableRow> 
        <TableRow 
         android:layout_weight="1" > 

      <Button 
      android:id="@+id/button4" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="40dp" 
      android:layout_marginTop="3dp" 

      android:background="@drawable/chipa" /> 
        </TableRow> 
        <TableRow 
        android:layout_weight="1" 
        > 
       <TextView 
      android:id="@+id/textView4" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Snacks" 
      android:layout_marginLeft="45dp" 
      android:textColor="#000000" 
      android:textSize="10dp"/> 
       </TableRow> 


      </TableLayout> 

누군가 해결책을 제시 할 수 있다면 .... 감사합니다. 당신이 할 수있는 일

+0

같은 선형 레이아웃을 사용할 수 있습니다; 모든 셀에서 layout_weight를 사용하면 열 정렬이 완전히 끊어지는 것으로 보입니다. –

답변

0

enter image description here

내가 조금 실험했습니다이

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

    <LinearLayout 
    android:id="@+id/layout_main" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" android:background="#2e8b57" android:layout_weight=".8" android:gravity="center"> 

    <LinearLayout 
    android:id="@+id/layout_main" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" android:layout_weight=".5"> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 
</LinearLayout> 

     <LinearLayout 
    android:id="@+id/layout_main" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" android:layout_weight=".5"> 
    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 
</LinearLayout> 

       <LinearLayout 
    android:id="@+id/layout_main" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" android:layout_weight=".5"> 
    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 
</LinearLayout> 

        <LinearLayout 
    android:id="@+id/layout_main" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" android:layout_weight=".5"> 
    <Button 
     android:id="@+id/button4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 

    </LinearLayout> 
    </LinearLayout> 

     <LinearLayout 
    android:id="@+id/layout_main" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:background="#8fbc8f" android:layout_weight=".2"> 
      <LinearLayout 
    android:id="@+id/layout_main" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" android:layout_weight=".8" android:gravity="center"> 



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

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

    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 



    <Button 
     android:id="@+id/button4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 


    </LinearLayout> 

       <LinearLayout 
    android:id="@+id/layout_main" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" android:layout_weight=".8" android:gravity="top|center"> 



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

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

    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 


    </LinearLayout> 
      </LinearLayout> 
</LinearLayout> 
+0

Avi, 네 .... 맞아 ... 선형 레이아웃을 사용 했었지만 테이블 레이아웃을 사용해야 할 필요가있다 ......... 테이블 레이아웃에서 가능한 것은 무엇입니까? –

+0

@KunalShah 괜찮아 보이거나 여전히 테이블 레이아웃을 사용해야하는 경우 레이아웃으로 이미지를 업로드했습니다. –

+0

Hmmmmmmm ...... 괜찮습니다 ... 그리고 Avi는 하나 더 의심 스럽습니다 .... 어떻게 지원하나요? 여러 화면에서 ... 안드로이드가 자원의 크기를 조정하면 작동할까요? –