【发布时间】:2018-01-17 14:59:27
【问题描述】:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.package.name.MainActivity">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="4"
android:rowCount="4">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_column="1"
android:layout_row="2"
android:src="@color/colorAccent"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_column="3"
android:layout_row="2"
android:src="@color/colorPrimary"/>
</GridLayout>
</LinearLayout>
这是我的布局文件。我期待一个 4x4 网格,第 1 列第 2 行中的强调色和第 3 列第 2 行中的原色,其余为空白。但相反,我只是让整个网格布局充满了强调色,甚至没有一个具有原色的单元格。为什么是这样?如何实现我想要的?
谢谢!
【问题讨论】:
标签: android android-layout grid-layout android-gridlayout