我有一个线性布局和里面的一个按钮。我希望按钮适合布局宽度的大约90%。以下一些教程中,我使用的属性layout_weight,这就是我的代码:Android的重量和布局宽度
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF"
android:weightSum="5" >
<Button
android:id="@+id/newgame"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:text="@string/newgame"
android:textSize="16sp"
android:typeface="monospace"
android:textStyle="bold"
android:background="@drawable/backrepeat" />
</LinearLayout>
现在,我的按钮消失,如果我设置layout_width到0dp像极了教程说...可能是什么问题呢? 在此先感谢。
改变方向的LinearLayout水平或添加重量为1的不可见视图。 – joao2fast4u
即使您使用重量,如果您使用正确的内容,您也只想知道方向t ...方向和价值... –