This is the code I am using and it is not working:
Use match_parent and gravity to set the TextView text to right, like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView android:text="TextView" android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
</TextView>
</LinearLayout>
With Linear Layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/select_car_book_tabbar"
android:gravity="right" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/my_booking_icon" />
</LinearLayout>

with FrameLayout
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/select_car_book_tabbar">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:src="@drawable/my_booking_icon" />
</FrameLayout>
with RelativeLayout
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/select_car_book_tabbar">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:src="@drawable/my_booking_icon" />
</RelativeLayout>
Add android:gravity="right" to LinearLayout. Assuming the TextView has layout_width="wrap_content"
setting the view's layout_weight="1" would do the trick.!
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
just add android:gravity="right" in your Liner Layout.
this is my xml, dynamic component to align right, in my case i use 3 button
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkinInputCodeMember">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="7"
android:orientation="vertical" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/bttn_extends"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/colorAccent"
android:text="3"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/bttn_checkout"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/colorAccent"
android:text="2"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/checkinButtonScanQrCodeMember"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/colorAccent"
android:text="1"/>
</LinearLayout>
and the result
you can hide the right first button with change visibility GONE, and this my code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkinInputCodeMember">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="7"
android:orientation="vertical" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/bttn_extends"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/colorAccent"
android:text="3"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/bttn_checkout"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/colorAccent"
android:text="2"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/checkinButtonScanQrCodeMember"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="1"
android:textColor="@color/colorAccent"
**android:visibility="gone"**/>
</LinearLayout>
still align right, after visibility gone first right component