gidLayout存在问题。我有一个这个网格:
这就是它在android studio中的样子。但是当我在平板电脑上安装应用程序时,所有元素看起来都很糟糕。
所有元素都正确放置在他的行和列中,但是 他们的背景不碰。就像layout_columnWeight和layout_rowWeight不起作用.. 请参阅200ºC文本元素:
网格布局的代码和xml中的所有元素:
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="12"
android:rowCount="12"
android:background="@color/black"
android:layout_weight="1"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Barra notificacions"
android:id="@+id/textView"
android:layout_row="0"
android:layout_column="0"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:gravity="center_vertical|center_horizontal"
android:background="@color/fondoGrid"
android:layout_margin="1dp"
android:layout_gravity="fill_horizontal"
android:layout_columnSpan="7" />
...other textViews
答案 0 :(得分:0)
您需要在网格布局上设置layout_width=wrap_content
。这应该解决问题。
我有类似的问题;但是,我的gridlayout包含在框架布局中,因此我必须将宽度设置为wrap_content。