LinearLayout으로만 작성한 이 화면 구성을 TableLayout이나 GridLayout으로 바꾸는 방법을 모르겠습니다.

조회수 1797회
<?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="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"></LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"></LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"></LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"></LinearLayout>
    </LinearLayout>

</LinearLayout>

지금 제가 이러한 화면구성을 작성하였습니다. 이렇게 작성하면 X,Y축으로 갈라져서 4개의 분면이 나오는 것이 되는 것인데, 이것을 그리드 레이아웃이나 테이블 레이아웃으로 어떻게 작성 할 수 있나요?

여러가지 방법을 해본것 같긴한데, weight라는 속성이 없어서 인지, 화면 밖으로 넘어가버리네요 ㅠ

  • (•́ ✖ •̀)
    알 수 없는 사용자

1 답변

  • 원하시는게 전부 grid나 table로 만드시는것 같은데 4개 분면만 linearlayout사용하고 그 안에 내용들을 table이나 grid를 사용해도 될 것 같습니다.

    <?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="match_parent"
        android:orientation="vertical">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1">
    
            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1">
    
                <TableRow>
                    <TextView android:text="Name" />
                    <TextView android:text="Name" />
                </TableRow>
            </TableLayout>
    
            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1">
    
                <TableRow>
                    <TextView android:text="Name" />
                    <TextView android:text="Name" />
                    <TextView android:text="Name" />
                </TableRow>
    
                <TableRow>
                    <TextView android:text="Name" />
                    <TextView android:text="Name" />
                    <TextView android:text="Name" />
    
                </TableRow>
    
    
            </TableLayout>
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1">
    
            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1">
                <TableRow>
                    <TextView android:text="Name" />
                    <TextView android:text="Name" />
                </TableRow>
    
            </TableLayout>
    
            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1">
                <TableRow>
                    <TextView android:text="Name" />
                    <TextView android:text="Name" />
                </TableRow>
    
            </TableLayout>
        </LinearLayout>
    
    </LinearLayout>
    
    • (•́ ✖ •̀)
      알 수 없는 사용자

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)