how to set text in button with image in center - android? - android

I have a button with inage in background and I set text for the button on the right of the image, how to set the text verticaly ??

For XML you'll need the android:gravity property, in code it would be TextView.setGravity() you're after.

Android:gravity in the XML. Set it to "center"
link text

Related

How to write this layout in xml

The TextView icon is not a Compound Drawable since the bottom line doesnt cover it.
How to define a layout like this where beside each text is an icon?
I just see ugly to add so much ViewGroups in the same view just to have the icon because there will be a lot of text input in the view.
use drawableLeft property of textview to set an icon with your text, it will create a single view with your icon and your text.
android:drawableLeft="#drawable/icon"
android:drawableBottom="#drawable/icon_line"

Underline text inside Editbox

As I enter text in editText it should automatically underline the text I entered. I need like as I continue to enter text in editText it draw like in background.
Can someone help me.
Use view with 1 dp of height and custom width with green background , inside framelayout over your editText, and handle custom_width same as you are handling image_width.
For underline effect in EditText you need to add this
//initialize edittext before
editText.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);

how can I set text between left and center in a TextView in Android, is there any way I can use margin for the text?

How can I put the texts in my white-colored textviews in Android in same location like those in my another pic? if I use android:gravity="left|center", it will be in the left-corner in the center, but I dont want it to be 100% left, what to do? is there any margin-type code for text in textView? Any tips would be appreciated, thanks
Use the android:paddingLeft attribute to add some space in your text view.

How to set padding to portion of text within TextView?

How to set padding to portion of text within TextView?
Specifically, i want to give left padding to part of text within textview.
Also, the text within textview is the data received from server. Any Help Appreciated.
Thanks!
Go to your layout file-> Go to your textView in layout-> android:paddingLeft="10".

Settings background for EDITTEXT cutting words in Android

I am having a strange issue, the words are cutting inside EDITTEXT i have set an image as background. Plz help me... for example here ffsds, is being cut, I want it to shift to bit right so that it doesnt get cut.
Increase paddingLeft value of edit text.
...
android:paddingLeft="100dp"
...
in xml layout.
Increasing the left padding is the easy solution. But if this smiley image is always on the left of the edittext, you can set the image by using the attribute android:drawableLeft on the edittext.

Categories

Resources