Issue
I have a button with an icon and a text inside of it. When I set the button's width to match_parent
, the text inside the button gets placed in the middle. I want the text to start from the right side of the button and not in the middle. How can I achieve this?
<Button
android:layout_margin="10dp"
android:id="@+id/select_flight_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/button_material_light"
android:drawableLeft="@drawable/icon_select_flight"
android:maxHeight="@dimen/global_button_height"
android:minHeight="@dimen/global_button_height"
android:text="@string/choose_flight"
android:textColor="@drawable/custom_text_color_for_buttons"
android:textSize="@dimen/button_text_size"
android:textStyle="bold"
android:layout_below="@+id/view"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
Solution
Picture and requirement doesn't match It is right and centerVertical and starting from right
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_action_accept"
android:gravity="right|center_vertical"
android:padding="15dp"
android:text="Chooose Flight "
android:textStyle="bold" />
Answered By - Zar E Ahmer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.