Equals width EditText?
I have a screen that has textviews and edittexts. I am trying to edittexts equal width. But they look very small width. I dont want to give a dip value. How can I do? Thanks a lot.
<TableLayout
android:id="@+id/TableLayout"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_centerHorizontal="true"
>
<TableRow>
开发者_如何学运维 <TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Name"
>
</TextView>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/name">
</EditText>
</TableRow>
<TableRow>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Last Name"
>
</TextView>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lastname">
</EditText>
</TableRow>
</TableLayout>
Why not wrap the following code in a Linearlayout, and add an attribute android:layout_weight=1 to both the TextView and EditText. This will help you to provide both of them of the same width!!
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Name"
>
</TextView>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/name">
</EditText>
Let me know if you have any queries
You can give equal layout weight to text and edit view Like android:layout_weight=".5"
The root of all problem is that you have given wrap content for all edit boxes. Since u have no default text or hint text, the size of it is set to minimum. Try adding a hint text or min width to get desired size boxes
put this line for edit text in xml android:singleLine="true"
精彩评论