<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_label_client_host"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/label_host" />
<EditText
android:id="@+id/et_client_host"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text"
android:layout_weight="1.0"
android:lines="1" />
</LinearLayout>
我希望 EditText
填充水平剩余的整个空间,但 TextView
和 EditText
获得可用空间的 1/2。此 LinearLayout
放置在另一个垂直 LinearLayout
内。
最佳答案
删除
android:ems="10"
对于所有元素,我在这里进行了测试并且它有效。
关于android - layout_weight=1.0 没有效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12727033/