As the title said, I want to put a little bit of space between the lock icon and the text.
And here is my current XML:
<EditText
android:id="#+id/guide_payment_settings_email_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginTop="5dp"
android:background="#drawable/border_paylpal_blue"
android:drawableLeft="#drawable/blue_rounded_lock"
android:hint="name#example.com"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textColor="#4d4e5b"
android:textSize="12sp" />
You have to add below line on your xml :-
android:drawablePadding="10dp"
above line give padding after drawable.
Related
I created an EditText with a drawable image. The problem is that the image is very close to the border of the EditText, is there a way to adjust it?
Note: Im using an svg file for the image
Image: In the image you can see the shoulder of the person is almost touching the left border
Code:
<EditText
android:id="#+id/sampleName"
android:drawableStart="#drawable/sampleImage"
android:drawablePadding="10dp"
android:layout_height="wrap_content"
android:maxLines="1"
android:layout_width="match_parent"
android:background="#color/white"
android:layout_marginLeft="5dp"
/>
You can try android:padding to the EditText along with the android:drawablePadding
Just add android:padding="5dp" . It will work .
Removing Below Line from your code will solve the problem :
android:layout_marginLeft="5dp"
You can use drawablePadding and paddingto give space to the image. Try it like this:
<EditText
android:id="#+id/sampleName"
android:drawableStart="#drawable/sampleImage"
android:drawablePadding="10dp"
android:layout_height="wrap_content"
android:maxLines="1"
android:layout_width="match_parent"
android:background="#color/white"
android:drawablePadding="5dp"
android:padding="5dp"
android:layout_marginLeft="5dp"
/>
Try this
<EditText
android:id="#+id/sampleName"
android:drawableStart="#drawable/sampleImage"
android:drawablePadding="10dp"
android:layout_height="wrap_content"
android:maxLines="1"
android:layout_width="match_parent"
android:background="#color/white"
android:padding="15dp"
android:layout_marginLeft="5dp"
/>
I want to set the hint of my AutocompleteTextView in a single line with extra string to be truncated with dots(...) in the end.
I am using singleLine="true", maxLines="1", ellipsize="end".
But still the hint is shown in two lines. Although The text is set to single line. But I need the hint should also need to shown in single line.
The Preview in Android Studio shows the hint in single line. But when I run it on Device it shows in 2 lines.(S5, Nexus-5, Nexus-6, J7).
I also want the imeOption should be always search. i.e. imeOptions="actionSearch" Hence I can't change it to actionNext.
Below is my XML Code:
<RelativeLayout
android:id="#+id/liLaySearchMap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:paddingLeft="10dp"
android:background="#color/cococo"
android:paddingRight="10dp">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/five_dp"
android:background="#color/white"
android:padding="#dimen/two_dp"
android:scrollHorizontally="true"
android:drawablePadding="#dimen/two_dp"
android:singleLine="true"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
android:textSize="#dimen/twelve_sp"
android:drawableLeft="#drawable/ic_action_search"
android:inputType="text"
android:hint="A Very Long Hint Text Which Need To Be Tuncated At the End In Single Line"
android:id="#+id/edSearch"
android:imeOptions="actionSearch"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/tvCancel"
/>
<TextView
android:id="#+id/tvCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:layout_margin="#dimen/five_dp"
android:text="#string/cancel"
android:textSize="#dimen/twelve_sp"
android:textColor="#color/tw__composer_red"
android:padding="#dimen/five_dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
Can Anyone Please en-curtain the issue I am facing. As I think I had used every possible solution but still the hint is not in single line.
these are screenshots on my Device and xml i tried is as follows
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#color/white"
android:padding="2dp"
android:scrollHorizontally="true"
android:drawablePadding="2dp"
android:singleLine="true"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
android:textSize="16sp"
android:inputType="text"
android:drawableLeft="#mipmap/ic_launcher"
android:hint="A Very Long Hint Text Which Need To Be Tuncated At the End In Single Line"
android:id="#+id/edSearch"
android:imeOptions="actionSearch"/>
try Setting android:inputType="text" on the AutoCompleteTextView it worked for me
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:inputType="text"
android:ellipsize="end"
android:imeOptions="actionNext"
android:hint="this is to check if it's getting truncated and in single line or not"/>
Setting android:inputType="text" on the AutoCompleteTextView it worked for me, unlike android:ellipsize="end", the text did not stay with '...' on end, but it does meet expectations.
android:completionThreshold="1"
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 taken an EditText as follows :
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="This is text"
android:drawableLeft="#drawable/search"
android:layout_centerInParent="true"/>
What if I want to set some spaces between that drawable icon and hint of EditText ?
For this use the attribute drawablePadding. This adds some padding between text and image.
Use android:drawablePadding property.
eg. android:drawablePadding="5dp"
Try this
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="This is text"
android:drawableLeft="#drawable/search"
android:layout_centerInParent="true"
android:drawablePadding="10dp" />
Add These Two Lines Of Code And you are good to go your icon will not touch the border of EditText and your icon and hint has some space in between As you can see in the pictures below
<EditText
android:drawablePadding="10dp"
android:paddingLeft="15dp"/>
I am trying to add a drawableleft to an Edittext:
<EditText
android:id="#+id/editUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/icon_email"
android:hint="#string/login_identity_hint"
android:textSize="12sp" />
Here is how it looks like:
As you see, the image does not match its parent's borders, there is padding from left, bottom and top even though i do not set any padding. What can i do about it?
I also tried the following approach:
<RelativeLayout
android:id="#+id/editUserNameContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView android:id="#+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/icon_email"
android:layout_alignParentLeft="true"/>
<EditText
android:layout_toRightOf="#+id/img"
android:id="#+id/editUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="5dp"
android:hint="hint"
android:textSize="12sp" />
</RelativeLayout>
But this time, it looks like the following: The image and edittext's heights do not match and there is a small gap between them:
Thanks.
I am thinking the only way you can get it to be how you want is to do something like this....
Remove android:drawablePadding="5dp" from EditText
Remove android:layout_toRightOf="#+id/img" from EditText
Add android:paddingLeft="50dp" to EditText
Add android:layout_alignParentLeft="true" to ImageView
This will just put the image over the top of your edit text, and using the padding to move the text in the edit text box to the right a bit after the image. You may need to make adjustments to the image view to make it fit just right
Let me know how this works!
<ImageView android:id="#+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/icon_email"
android:layout_alignParentLeft="true"/>
<EditText
android:layout_alignParentLeft="true"
android:id="#+id/editUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="50dp"
android:hint="hint"
android:textSize="12sp" />