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"
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 want to make drawable and text center in my EditText. The text is centered but the drawable is not. I want something like this:
http://i.imgur.com/cacxR2C.jpg?1
Please help. This is what I have done so far
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:gravity="center_horizontal"
android:drawableLeft="#drawable/lol2"
/>
When the user types in something in the EditText, the drawable should move itself to the left if the text is lenghty.
You can do something like this
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#android:drawable/editbox_background"
>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Username"
android:background="#null"
android:gravity="center"
android:drawableLeft="#drawable/ic_launcher"
/>
</RelativeLayout>
This worked for me:
<EditText
android:id="#+id/searchET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="75dp"
android:paddingEnd="75dp"
android:inputType="text"
android:singleLine="true"
android:gravity="center"
android:hint=" Username"
android:drawableStart="#drawable/your_icon"
android:background="#android:drawable/editbox_background"/>
The kicker here is that you wrap_content for the width, align the text however, center the view however you'd like, then add padding to each end of the edit text.
This shoves the drawable to the start of your text but still lets you expand your edit text background.
instead of
android:drawableLeft="#drawable/lol2"
try using
android:drawableStart="#drawable/lol2"
Basically gravity attribute is used to apply changes of aligning the contents of lay out so you can put the gravity to center to align contents in center and center_vertical to to align contents on left side and gravity to center_horizontal to put contents in horizontal center. i.e
android:gravity="center"
this is my layout
<HorizontalScrollView
android:layout_width="175dp"
android:layout_height="match_parent"
android:scrollbarFadeDuration="5">
<TextView
android:id="#+id/documentName"
android:layout_width="175dp"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:paddingLeft="5dp"
android:scrollHorizontally="true"
android:selectAllOnFocus="true"
android:singleLine="true"
android:text="Untitled Document123456789"
android:textColor="#ffffff"
android:textSize="20dp" />
</HorizontalScrollView>
Case 1: When i use text view alone, it shows Untitled Document... (...)denoting some text is hidden but i didn't get the horozontal scroll. Then i surround text view with horizontal scroll, i got the scroll but not the dotted text denoting some text is hidden
Please correct my layout if am missing anything.
Add this to your textview
android:ellipsize="start"
Instead of start you can have other values: end, middle ... You can look up at http://developer.android.com/reference/android/widget/TextView.html#attr_android:ellipsize
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
I have an edittext.
From the code I set it with hebrew text, however the text is left align (to the left border of the edittext)
Here it the part from the XML file:
<EditText
android:layout_height="wrap_content"
android:layout_width="240dip"
android:textColor="#color/black"
android:inputType="textMultiLine"
android:gravity="right"
android:lines="7"
android:layout_marginTop="5dip"
android:background="#drawable/field"
android:id="#+id/userEditTextId"
android:textSize="14dp"
android:hint="כתוב פה..." />
yeh, people are still asking that question until recently
http://groups.google.com/group/android-developers/browse_thread/thread/971bd9df400ca89e