Android的RelativeLayout的layout_height属性设置为wrap_content时layout_below等无效
16lz
2021-01-23
RT
RelativeLayout中,如果将 TextView的
android:layout_height=”wrap_content”
android:layout_centerVertical=”true”
之后,其他的控件的android:layout_below等属性全部失效
发现限制行数也无效
最后时候minHeight解决问题
<TextView android:id="@+id/view_top_user_info_nickname" style="@style/x_standard_text_5" android:layout_width="match_parent" android:layout_height="wrap_content" **android:minHeight="30dp"** android:layout_centerVertical="true" android:singleLine="true" android:textColor="@color/standard_black" /><TextView android:id="@+id/view_top_user_info_signature" style="@style/x_standard_text_6" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/view_top_user_info_nickname" android:singleLine="true" android:text="asdfadfadf啊啊士大夫撒的发撒撒的发阿斯蒂芬asd啊" android:textColor="@color/standard_gren_1" />
网上有朋友说将:
RelativeLayout布局的layout_height属性设置为match_parent即可!
即使外层有LinearLayout使用layout_weight平分空间,它的match_parent也不会撑大外层LinearLayout的空间的。
当初想设置wrap_content,其实就是怕内部的RelativeLayout设置match_parent后会被撑大而已,实践证明,多虑了!
http://www.th7.cn/Program/Android/201410/297261.shtml
但是这样修改对布局影响较大,所有我没有采纳
更多相关文章
- Android之activity属性汇总
- Android 布局属性全解(初学者必学)
- TextView 属性详解
- Android卡片式列表布局
- Android XML布局报错:android/view/View$OnUnhandledKeyEventList
- android布局layout中的一些属性
- Android——EditText【输入框】的所有属性和常用属性归纳