I am using some customized RadioButtons in Android. Unfortunately the text can't be aligned in the center altough I set the gravity and textAlignment attributes to "center". You can see in my screenshot that the text is more on the right side:
Here you see the code: Radio Button in the constraintLayout:
<RadioButton
android:id="@+id/r_Button_Small"
android:layout_width="@dimen/_73sdp"
android:layout_height="@dimen/_28sdp"
android:layout_weight="1"
android:textSize="@dimen/_12ssp"
android:background="@drawable/background_selector"
android:text="@string/small"
android:textColor="@drawable/text_selector"
android:gravity="center"
android:textAlignment="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.322"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginLeft="@dimen/_50sdp"
app:layout_constraintVertical_bias="0.584"
/>
Background files
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_checked="true"
android:drawable="@drawable/state_checked" />
<item android:drawable="@drawable/state_unchecked" />
</selector>
with state file "checked"
<?xml version="1.0" encoding="UTF-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colorBlue">
</solid>
<corners android:radius="@dimen/_25sdp"></corners>
</shape>
and "state uncheched"
<?xml version="1.0" encoding="UTF-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colorTest">
</solid>
<corners android:radius="@dimen/_25sdp"></corners>
</shape>
If you are wondering what "@dimen/_25sdp" is: It is scalable size unit from https://github.com/intuit/sdp
Do you know how I can align the text into the center? I'appreciate every comment and would be thankful for your help.