当我通过android studio运行模拟器时,将以下xml中的android:layout_width更改为任何值(例如99999dp)似乎没有做任何事情。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send" />
</LinearLayout>
答案 0 :(得分:0)
您的EditText
有android:layout_weight="1"
。使用重量时,不考虑宽度,应将其设置为0.如果移除重量,则应能够根据需要设置宽度。