Center an image inside a TextView

0

How do I center an image inside a TextView? I used the attribute:

android:drawableStart="@drawable/email"

But the image is decentralized:

In this case I can work with this image inside the TextView or in my case is it better to use an ImageView then a TextView?

Thank you

    
asked by anonymous 21.10.2018 / 16:03

1 answer

0

If this is not the solution please answer the post with the XML code.

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:drawableLeft="@drawable/some_drawable"
    android:text="some text"
    android:layout_gravity="center"
    android:gravity="center"
    />

Try using the properties below to align the hint and image to the center, I did a quick test here and it worked perfectly.

android:layout_gravity="center"
android:gravity="center"

android: layout_gravity Gravity specifies how a component should be placed in its group of cells.

gravity Gravity for the view associated with these LayoutParams.

    
22.10.2018 / 15:35