Hello i'm facing a little problem
I'm using GRAVITY LEFT to make my text an aligment for the left side of a view but I want to center inside the textview but also align on the left part
Here's what I have now:
___________________________________
_ _ _ _ _ _| aaaaaaaaaaaaa |_ _ _ _ _ _
_ _ _ _ _ _| aaaaaaaa |_ _ _ _ _ _
_ _ _ _ _ _| aaaaaaaaaaaaaa |_ _ _ _ _ _
-----------------------------------
What I want is:
___________________________________
_ _ _ _ _ _| aaaaaaaaaaa |_ _ _ _ _ _
_ _ _ _ _ _| aaaaaaaa |_ _ _ _ _ _
_ _ _ _ _ _| aaaaaaaaaaaaaa |_ _ _ _ _ _
-----------------------------------
Where:
_ _ _ _ = outside of textview
| = the TextView edge
I tried android:gravity = "left|center" but it doesn't work, any idea ?
Thanks
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/image_button_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_centerVertical="true">
<ImageView
android:id="@+id/left_button_image"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/spacing_normal"/>
<Textview
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/left_button_image"
android:gravity = "center|left|left"
android:clickable="false"
android:focusable="false"
app:font_name="Roboto-Light.ttf"/>
What i've (text align left but not centered)
What i want (text align left and centered) (I add a padding manually to get the render but it's dirty and will not adapt to all text) :
Just give Textview parent as:
android:gravity = "center"
Just give Textview as:
android:gravity = "center_vertical|left|start"
android:layout_margin="20dp"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With