如何使 2 個 TextInputs 填充螢屏的寬度?我也想要他們之間的小空間
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TEST 1"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TEST 2"
/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
現在的樣子:

我希望它看起來如何:

uj5u.com熱心網友回復:
你用weightSum. 請參閱已編輯的 XML。記下paddingEnd,我加了paddingLeft。android:layout_width="0dp"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:weightSum="2"
>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingEnd="10dp"
>
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TEST 1"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="10dp"
>
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TEST 2"
/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/521262.html
上一篇:FATALEXCEPITON,androidstudio一直在為一個按鈕崩潰;
下一篇:單個引數的inheritdoc?
