How do I give my EditText-s a fixed width. This is my code
<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>
I've tried attributes android:maxLines and android:maxWidth but i've not been able to solve the problem.
Thanks.
在 .xml 文件中,您可以这样做:
<EditText ... android:layout_width="28dp" .../>
Your LinearLayout's android:orientation is horizontal. You can change it to vertical.
android:orientation="vertical"
You can fixed width of your edittext by using code:
EditText dittext = (EditText)findViewById(R.id.sometextview);
edittext.setMaxWidth(edittext.getWidth());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.