3

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!!:)

noobProgrammer
  • 1,443
  • 4
  • 14
  • 33

3 Answers3

1

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

Thai Tran
  • 9,815
  • 7
  • 43
  • 64
  • well i want an edittext that is like the first image.The second inserts the text in the center...sorry for my poor english i hope you understand me – noobProgrammer Sep 03 '13 at 11:00
  • Have you checked the code that I posted in the update? The `TableLayout` has the `layout_height` is `wrap_content` instead of `match_parent` – Thai Tran Sep 03 '13 at 11:32
  • not sure what you mean about "center". My above code gives the text left align. Check out my screenshot – Thai Tran Sep 04 '13 at 05:29
  • @noobProgrammer might as well put your previous comment as an answer. It's the correct solution for me too. :) – vida Oct 30 '13 at 17:43
1

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

Ritaban
  • 763
  • 4
  • 8
0

I just changed the gravity : Using the following code

  <RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"

        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_weight="0.62" >

      <EditText
          android:id="@+id/editText1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentRight="true"
          android:layout_alignParentTop="true"
          android:ems="10"
          android:gravity="left"
          android:inputType="textPersonName" >
          <requestFocus />
      </EditText>  
        </RelativeLayout>

Screenshot:

Screenshot:

noobProgrammer
  • 1,443
  • 4
  • 14
  • 33