Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MultiLine EditText in Android with the cursor starting on top [duplicate]

I know it seems it's an already thousand times answered issue but I haven't found anything that works for me.

I have a MultiLine EditText on Android that adapts to the view size by "playing" with the weight (1) and the height (0dip). I am using gravity "top" but it starts in the middle.

I guess the problem it's related with the weight. Here's the code (the parent is a LinearLayout):

    <EditText
        android:id="@+id/txtContacto"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_gravity="top"
        android:inputType="textMultiLine" 
        android:weight="1">
    </EditText>
like image 314
Keyser Sozé Avatar asked May 08 '12 17:05

Keyser Sozé


1 Answers

<EditText
        android:id="@+id/txtContacto"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:gravity="top"
        android:inputType="textMultiLine" 
        android:weight="1">
    </EditText>

try the above code.. where layout gravity sets the edittext and gravity sets the content of edittext.

like image 147
Shankar Agarwal Avatar answered Sep 22 '22 07:09

Shankar Agarwal