浅析layout_weight属性,gravity属性,layout_gravity属性
发布时间:2020-12-16 09:01:02 所属栏目:百科 来源:网络整理
导读:参考:http://developer.android.com/guide/topics/ui/layout/linear.html layout_weight属性 基于LinearLayout 下的view 布局权重,意味这个view在当前布局中占据多大空间(比重) 拥有更大weight值的view被允许扩展填充满parent view.(填满剩余空间) 所有v
参考:http://developer.android.com/guide/topics/ui/layout/linear.html layout_weight属性 <基于LinearLayout 下的view>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">
<EditText android:id="@+id/one" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="one" />
<EditText android:id="@+id/two" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:hint="two" />
</LinearLayout>
在上述xml中。two的layout_height值设置为任意值都不会影响布局结果,一般我们设置为0dp。 gravity属性
layout_gravity属性
注意:当我们把layout_width 或 layout_height 的值设置为负值时,系统会按照 warp_content 处理。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |