MultiLine EditText in Android with the cursor starting on top

AndroidAndroid LayoutAndroid Edittext

Android Problem Overview


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>

Android Solutions


Solution 1 - Android

<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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKeyser Soz&#233;View Question on Stackoverflow
Solution 1 - AndroidShankar AgarwalView Answer on Stackoverflow