android - 如何按颜色填充网格单元格
问题描述
我需要用背景颜色填充整个单元格,但我得到了这个: 我在任何地方都使用了“match_parent”并且它什么也没给出,请帮助代码:
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gucciBlack"
android:padding="3dp">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/gucciRed"
android:text="@string/days" />
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_row="0"
android:background="@color/gucciRed"
android:text="mon" />
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="1"
android:background="@color/gucciLazur"
android:text="tue" />
... other checkboxes (same code) ...
</android.support.v7.widget.CardView>
解决方案
发生这种情况是因为您的TextView
宽度和高度设置为"wrap_content"
. 尝试将它们更改"match_parent"
为 ,如下所示:
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_column="0"
android:layout_row="0"
android:background="@color/gucciRed"
android:text="@string/days" />
推荐阅读
- apache-spark - 某些数据框列中的空值,同时从 hbase 读取它
- css - 是否可以在 CSS 中制作一个顶部宽度为“A”、底部宽度为“B”的 div,所以右侧是对角线?
- cassandra - 如何在旧的 SSTables 中删除 Cassandra 墓碑?
- android - 如何使用 Fire base 在可扩展列表的单行内显示多个文本视图
- solidity - 以太坊合约,运行函数会破坏合约成员
- assembly - 分段故障组装调试
- javascript - 在父组件中动态加载子组件
- javascript - 使用 Flow - 如何使用 DocumentRef 检查 DataSnapshot 字段的类型?
- java - 如何从 scala 2.11 执行 BASH 源命令?
- ios - 显示具有不同扩展名的不同远程文档/附件