이 질문에 대한 답변을하지 못 했으므로 다른 인스턴스를 추가하겠습니다. 오리지널은 여기에 있습니다. 정확하게 제 문제입니다. 다음은 XML은 다음과 같습니다GridLayout이 제대로 표시되지 않고 미리보기와 일치하지 않습니다.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.slidamusic.gridlayoutdemo.GridDemo">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:text="New Button"
android:id="@+id/button"
android:layout_row="0"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_column="0" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:text="New Button"
android:id="@+id/button1"
android:layout_row="0"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_column="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:text="New Button"
android:id="@+id/button2"
android:layout_row="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_column="0" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:text="New Button"
android:id="@+id/button3"
android:layout_row="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_column="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:text="New Button"
android:id="@+id/button4"
android:layout_row="2"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_column="0" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:text="New Button"
android:id="@+id/button5"
android:layout_row="2"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_column="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:text="New Button"
android:id="@+id/button6"
android:layout_row="3"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_column="0" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:text="New Button"
android:id="@+id/button7"
android:layout_row="3"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_column="1" />
</GridLayout>
그것은 미리보기에서 모두 완벽하게 정렬하고 동일하게 2 COLS, 4 행 크기의 8 개 버튼과 같은 매우 간단한 레이아웃입니다. 내 태블릿에서 프로그램을 실행하면 상황이 더 많거나 적은 다음과 같이 더 무질서 많이있다 : 나는 문제가 안드로이드와 함께있을 수 있다는 것을 가정 한
GridLayout does not expand elements evenly
: layout_gravity이 = 내가 제거 할 때와 같이 "입력" 이 라인은 버튼이 정상 크기이고 줄이 잘 잡혀 있지만, 원하는대로 화면을 채우지 않으며 미리보기에 표시됩니다.