【发布时间】:2016-04-01 17:18:16
【问题描述】:
我如何给我的 EditText-s 一个固定的宽度。这是我的代码
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="4dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date:"
android:layout_weight="0"
android:textColor="#FFBBB3B9" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#c91f1f"
android:saveEnabled="true"
android:id="@+id/e1b"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time:"
android:layout_weight="0"
android:textColor="#FFBBB3B9" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#c91f1f"
android:id="@+id/e1c"
android:saveEnabled="true"
/>
</LinearLayout>
我试过属性 android:maxLines 和 android:maxWidth 但我无法解决问题。
谢谢。
【问题讨论】:
-
您可以在 dp 中指定宽度或使用 maxEms 属性