开发者

How to have same height for TextView as for EditText?

I have a view with 3 lines, in one of them with 2 TextViews, in the other 2 one TextView and one EditText. How can I have the same height for all those lines, and the size of the TextView which replaces an EditText in one line have the same size as the other EditTexts?

Regards, Eddie

Example code here: I would like to have the 2nd TextView in the first line to have the same size (of the view itself and of the text within it) as for the EditText in the following lines.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    >
<LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        >
    <TextView
            android:text="Datum:"
            android:layout_width="60dip" 
 开发者_C百科           android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            />
    <TextView
            android:id="@+id/datum"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:layout_alignParentRight="true"
            />
</LinearLayout>
<LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        >
    <TextView
            android:text="Zweck:"
            android:layout_width="60dip" 
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            />
    <EditText
            android:id="@+id/title"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:layout_alignParentRight="true"
            android:inputType="textNoSuggestions"
            />
</LinearLayout>
<LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        >
    <TextView
            android:text="Betrag:"
            android:layout_width="60dip" 
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            />
    <EditText
            android:id="@+id/value"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:inputType="numberDecimal|textNoSuggestions"
            android:layout_alignParentRight="true"
            />
</LinearLayout>


Can you post your example code?

You can use distinct sizes by using android:layout_width="wrap_content" and /or android:width="300dp" (same for height). Also check margins and paddings.

If you need to be more dynamic, you might consider android:layout_weight i.e. for letting 2 buttons have equal width and fill the horizontal space of the parent view you would set: android:layout_width="wrap_content" android_layout:weight="0.5".

Edit: They seem to be all the same size (filling the space left by the description on the left). Do you want to increase the font size of the TextView?

You could also use an EditText in all three columns but set the first to android:editable="false".


You can use android:layout_height="match_parent"


android:editable="false" is deprecated.

Use android:inputType="none" instead

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜