Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText height-length

I have been trying to create a simple note pad and I can't create in xml file an EditText that would match parent like that:

notepad

in xml:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:ems="10" >

        <requestFocus />
    </EditText>

</TableLayout>

I want full screen to be match parent with the editText.

not like this...... I want text that it would be entered in left align

picc

please help!!:)

like image 650
noobProgrammer Avatar asked Apr 18 '26 12:04

noobProgrammer


2 Answers

Try giving your edit text layout width as FILL_PARENT or MATCH_PARENT.

like image 64
Ritaban Avatar answered Apr 21 '26 03:04

Ritaban


Change your android:layout_width="wrap_content" into android:layout_width="match_parent".

Update According to your updating image, it is because you set the parent layout (table layout) height to match with the screen. Set it back to wrap content and then you will have what you want

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10" >

        <requestFocus />
    </EditText>

</TableLayout>

And here is the result

enter image description here

like image 23
Thai Tran Avatar answered Apr 21 '26 03:04

Thai Tran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!