Questions tagged «android-layout-weight»

18
Android中的线性布局和权重
我总是在Android文档中读到这个有趣的体重值。现在,我想第一次尝试,但它根本没有用。 据我从文档中了解,此布局: <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" weight="1" /> </LinearLayout> 应该创建两个水平对齐的按钮,并平均分配空间。问题在于这两个按钮没有增长来填充空间。 我希望按钮能够增长并填满整个生产线。如果两个按钮都设置为与父按钮匹配,则仅显示第一个按钮并填满整行。



By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.