GridLayout 中 TextView 的动态高度 [英] Dynamic height of TextView within a GridLayout
问题描述
我在使用具有库兼容性的 GridLayout 时遇到问题(没有尝试过).我正在使用 app:layout_gravity="fill_horizontal"
而不是 android:layout_gravity="fill_horizontal"
但 TextView
内的所有内容均未显示.为了显示所有内容,我必须设置 TextView
标题"的高度,但我想要一个动态高度,而不是设定高度.
I have a problem using GridLayout using library compatibility (not tried without). I am using app:layout_gravity="fill_horizontal"
instead of android:layout_gravity="fill_horizontal"
but all the content inside the TextView
is not displayed. In order to display everything, I have to set the height of the TextView
"Title" but I want a dynamic height, not a set height.
有什么想法吗?
推荐答案
你必须为 TextView 设置 layout_width="0dp"
和 layout_gravity="fill_horizontal"
.
You have to set layout_width="0dp"
and layout_gravity="fill_horizontal"
for the TextView.
<TextView
android:layout_width="0dp"
android:layout_gravity="fill_horizontal" />
请在此处查看完整示例:https://groups.google.com/d/msg/android-developers/OmH3VBwesOQ/ZOGR0SGvC3cJ 或此处:http://daniel-codes.blogspot.com/2012/01/gridlayout-view-clipping-issues.html
Please, see full example here: https://groups.google.com/d/msg/android-developers/OmH3VBwesOQ/ZOGR0SGvC3cJ or here: http://daniel-codes.blogspot.com/2012/01/gridlayout-view-clipping-issues.html
这篇关于GridLayout 中 TextView 的动态高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!