I have an EditBox in which I set the input type as textMultiLine. The issue is that the cursor in the EditBox always appears at the center of the EditBox, But I want it to display at the top left of my EditBox.
So why this happens?
Code for EditBox
<EditText
android:id="#+id/notes_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:background="#drawable/img_add_notes_textbox"
android:inputType="textMultiLine"
android:maxHeight="30dp"
android:paddingLeft="15dp"
android:scrollbars="vertical"
android:textColor="#121212" >
</EditText>
ScreenShots
Because, by default gravity of EditText is center so just set it to top
android:gravity="top"
You need to set android:gravity="top|left" to your EditText
Related
I have a EditText in my app and i would like to align the text in it a bit more to the right is there a would to do this by axml?
To move your text to right side in your editText,you can use gravity and padding.
Check this here:
<EditText
android:id="#+id/edt_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:paddingLeft="10dp"
android:text="Test"
android:hint="Email"
android:singleLine="true"
android:textSize="18sp" />
Try adding android:gravity="right" to the EditText
I have a very big text field but writing on it is not as I'd like. Is there a way I can move cursor to the top left of the field (so that it looks like a text area). Because by default it is centered. Thanks a lot
I use:
<EditText
android:layout_width="400dp"
android:layout_height="500dp"
android:id="#+id/editText"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
Add android:gravity attribute to EditText with value top|left.
android:gravity="top|left"
I m using an image in edittext. image is quite big so the cursor come in middle
<EditText
android:id="#+id/titletobeset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="200dp"
android:maxLines="200"
android:background="#drawable/wallpape"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:cursorVisible="true">
</EditText>
use
android:gravity="left|top"
in gravity you can set the position of text which is indeed the starting position of the cursor
try to add following properties in your edit text
android:gravity="top"
android:inputType="textMultiLine"
I display emoji in EditText using spannable, but the problem is that the text appears in the bottom of the emoji picture, not in the middle of it (see picture).
So, how to make it display in the middle?
<EditText
android:id="#+id/et_tInput"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:inputType="textCapSentences|textMultiLine"
android:maxLength="2000"
android:maxLines="4"
android:textColor="#android:color/black"
android:textCursorDrawable="#drawable/black_cursor"/>
Set gravity center for your TextView
android:gravity="center"
or
android:gravity="center_vertical"
I have an EditText with the property:
android:minLines="3"
However, when I start typing, it types in the middle of the EditText.
Is there any way to get this to start typing at the top left of the EditText area?
Add android:gravity="top|left" to the EditText in the layout XML file.
Just insert
android:gravity="top"
into your EditText.
android:gravity="start" would put it to the top left.
This will help you. Try this EditText....
<EditText
android:id="#+id/edt_comment_note"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="#drawable/white_box"
android:gravity="top"
android:hint="Note"
android:imeOptions="actionDone"
android:maxLines="3"
android:padding="5dp"
android:textSize="15sp" />