为什么我要android:layout_width="0px"
在使用ndroid:layout_weight
属性时放置?例如下面是我的 main.xml 文件,我使用了android:layout_width="wrap_content"
,一切正常,那么为什么android:layout_width="0px"
在我使用 layout_weight 属性时应该使用呢?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText" android:hint="enter your name"
android:layout_weight="3"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send"
android:id="@+id/button"
android:layout_weight="0"/>
</LinearLayout>
这就是我的布局的样子: