2016-07-06 2 views
2

HELP TableLayout & TableRow를 사용하여 아래 사진에서 No.1과 마찬가지로 No.4와 No.6을 함께 사용하려고했지만 어떻게해야하는지 잘 모르고있었습니다. no.1의 경우 레이아웃 - 무게를 사용하여 화면을 3 열, 3 열로 나눌 수있었습니다. TableLayout을 사용하여 원하는 디자인을 만드는 방법은 무엇입니까?

<TableLayout 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:stretchColumns="*"> 
<TableRow 
    android:layout_weight="2" 
    android:id="@+id/tableRow1"> 
    <TextView 
     android:text="1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="center" 
     android:background="@android:color/holo_blue_dark" /> 
    <TableLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_span="2" 
     android:stretchColumns="*" 
     android:id="@+id/tableLayout1"> 
     <TableRow 
      android:layout_weight="1" 
      android:id="@+id/tableRow1" 
      android:background="@android:color/holo_red_dark"> 
      <TextView 
       android:text="2" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_span="2" 
       android:gravity="center" /> 
     </TableRow> 
     <TableRow 
      android:layout_weight="1" 
      android:id="@+id/tableRow3"> 
      <TextView 
       android:text="3" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:gravity="center" /> 
      <TextView 
       android:text="4" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:gravity="center" /> 
     </TableRow> 
    </TableLayout> 
</TableRow> 
<TableRow 
    android:layout_weight="1" 
    android:id="@+id/tableRow1"> 
    <TextView 
     android:text="5" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_span="2" 
     android:gravity="center" 
     android:background="@android:color/holo_green_dark" /> 
    <TextView 
     android:text="6" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="right" /> 
</TableRow> 
IMG 아래

enter image description here

내가 사용 GridLayout enter image description here

+0

내 대답을 참조하십시오. 이게 너를 도와 줄거야. –

답변

1

를 원하는 결과입니다. 화면 편집 한

Screenshot

그냥

android:layout_height="match_parent" 
을 대체 촬영

<?xml version="1.0" encoding="utf-8"?> 
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:padding="5dp" 
android:rowCount="3" 
android:columnCount="3" 
android:layout_height="wrap_content"> 


<Button 
android:text="1" 
android:layout_height="wrap_content" 
android:layout_gravity="fill_vertical" 
android:layout_rowSpan="2" 
android:layout_width="wrap_content" 
android:background="#abc012"/> 

<Button 
android:text="2" 
android:layout_columnSpan="2" 
android:layout_gravity="fill_horizontal" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:background="#a01012"/> 
<Button 
android:text="3" 
android:layout_gravity="fill" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:background="#10fa5c"/> 

<Button 
android:text="4" 
android:layout_rowSpan="2" 
android:layout_gravity="fill_vertical" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:background="#9d34a1"/> 

<Button 
android:text="5" 
android:layout_gravity="fill_horizontal" 
android:layout_columnSpan="2" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:background="#f0f53f"/> 

</GridLayout> 

이 다음 코드를 사용해보십시오 16,

대신 <GridLayout>에서

android:layout_height="wrap_content" 

. 그러면 출력은 다음과 같이 출력됩니다.

enter image description here

+0

안녕하세요, 도와 줘서 고마워, 미안, 난 여전히 초보자 이걸로, 내가 수평선으로 만들려고 gridlayout의 높이 match_parent하지만 크기의 조정 난 엉망 전체 화면과 빈 공간이 무엇입니까 ?? 어떻게하는지 가르쳐 줄 수 있니? –

+0

내 edit1 참조. 네가 원하는 걸 보여줄거야. –

관련 문제