Issue
I am trying to make it so that the Button
in the LinearLayout
starts from the right side and to set the Button
5dp
from the right edge of the LinearLayout
, with the TextView
showing to the left of the button. Currently, it only allows to set the button from the "left" edge of the linear layout. I've tried all sorts of ways but nothing seems to work.
<LinearLayout
android:id="@+id/remote_button_layout"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="30dp"
android:background="@drawable/btn_remote_button"
android:orientation="horizontal">
<TextView
android:text="Example Text"
android:textSize="10sp"
android:fontFamily="@font/mmedium"
android:textAllCaps="false"
android:layout_width="125dp"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="@android:color/secondary_text_light"/>
<Button
android:id="@+id/btn_remote_button"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:background="@drawable/btn_remote_button"
android:drawableStart="@drawable/logo"
app:layout_constraintHorizontal_bias="1.0" />
</LinearLayout>
Solution
You have to add android:gravity="right"
in Layout. So all the inner widgets will be set from right to left manner. Like below.
<LinearLayout
android:id="@+id/remote_button_layout"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="30dp"
android:gravity="right
android:background="@drawable/btn_remote_button"
android:orientation="horizontal">
Answered By - Pratik Satani
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.