I have to do some flattening on my layout, below piece of it after. Percent TextView
and RadioButton
are in same place on the left and are switching using animations. Second TextView
shows some text fulfilling width. Problem is that RadioButton
is shorter than percent TextView
, but I'm using alignLeft
and alignRight
for same width, and even with gravity set to center
radio drawable is aligned left. I've found this topic, but is a bit old, before Material, and currently this class is more complicated. Any advice how to center this radio in own width (or width of percent textview) without! adding another ViewGroup
? (precent and radio might be in another RelativeLayout
and set centerInParent
, as I had before tries for flattening)
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/option_percent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:singleLine="true"
android:gravity="center"
android:ems="3"
android:visibility="invisible"/>
<RadioButton
android:id="@+id/option_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignLeft="@id/option_percent"
android:layout_alignRight="@id/option_percent"
android:gravity="center"/>
<TextView
android:id="@+id/option_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/option_percent"/>
</RelativeLayout>