Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I place the text inside an EditText widget at the top?

I have the following xml for an edittext and button which take the whole screen. The only problem is I can't find a way to make the typed text in the edittext to be put at the top. Right now it's put in the centre of the editText.

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:background="@drawable/herinnering_background"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">



        <EditText
            android:id="@+id/invoerTekst"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:hint="@string/prompt_tekst" />

        <Button
            android:id="@+id/klaar"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:text="@string/action_sla_op"
            android:background="@drawable/main_button_over"
            android:textColor="#ffffff"
            android:layout_margin="5dip"
            android:layout_below="@id/invoerTekst" />



    </LinearLayout>
like image 767
Vincent Avatar asked Apr 29 '11 13:04

Vincent


2 Answers

Add android:gravity="top" attribute to your EditText.

like image 107
ernazm Avatar answered Oct 06 '22 00:10

ernazm


Use this, It will help you.

EditText

    android:id="@+id/invoerTekst"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:gravity="top"
    android:hint="@string/prompt_tekst" 
like image 44
Datta Kunde Avatar answered Oct 06 '22 00:10

Datta Kunde