android - 当孩子的身高不同时,均匀对齐gridview
问题描述
我有这个 GridView:
<GridView
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:stretchMode="columnWidth"
android:numColumns="2"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:clipToPadding="false"
android:padding="10dp"
android:scrollbars="none"
android:drawSelectorOnTop="true"/>
有 99% 的孩子身高相同。没问题,它看起来像这样。
---- ----
| | | |
| | | |
---- ----
---- ----
| | | |
| | | |
---- ----
---- ----
| | | |
| | | |
---- ----
1% 的情况下,一个孩子可能比他的兄弟姐妹高,结果是
---- ----
| | | |
| | | |
| | ----
---- ----
| | | |
| | | |
---- ----
---- ----
| | | |
| | | |
---- ----
如图所示,孩子 1 与其下方的兄弟重叠。
这就是想要实现的目标:
---- ----
| | | |
| | | |
| | ----
----
---- ----
| | | |
| | | |
---- ----
---- ----
| | | |
| | | |
---- ----
如您所见,中间的两个孩子进行了调整,以便孩子 1 有足够的空间来绘制它的视图。
为我的 gridview 尝试了不同的配置,但失败了。我被困住了,需要帮助。
解决方案
kindly refer this url , use Recylerview
instead of GridView
in xml.
https://abhiandroid.com/materialdesign/recyclerview-gridview.html
推荐阅读
- asp.net - .NET 框架项目中的 ReactJS - 无法在模块外使用 import 语句
- sql - 如何使用 Oracle Join and Case 仅返回 1 行?
- firebase - 导出到单个字符串字段的所有文档属性
- mysql - mysql 选择这个公式 E < X <=2E & X > 3E
- swift - 变量名与内置函数冲突
- matlab - 文件标识符可以在 Matlab fprintf 中指定一个字符串作为输出吗?
- macos - webcal:// 链接不再在 MacOS 上打开 Apple 日历
- javascript - 如何使用外部 HTML 文件制作 Web 组件?
- c++ - 如何在 c++11 中的默认移动构造函数末尾添加打印语句?
- python-3.x - 如何在 AWS Cloud9 中安装 chromedriver?