Android studio how to rotate buttons and align them to right/left side of the parent view?

Viewed 243

I want rotate buttons and align them to right/left side of the parent view(picture 1). In the left button I could achieve it by setting the layout_marginLeft to "-20dp". The right button is the problem here. When I set maring lets say to 300dp, button not only moves to right side of the parrent (this is what I want) but also gets smaller (picture 2)(i dont want that)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:id="@+id/buttons_top">
    <Button
        android:id="@+id/top_button"
        android:layout_width="126dp"
        android:layout_height="wrap_content"
        android:background="@drawable/mafia_buttons_background"
        android:layout_centerHorizontal="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="10dp"
        android:textColor="@color/white"
        android:textAllCaps="false"
        android:rotation="180"
        app:autoSizePresetSizes="@array/auto_size_text_sizes"
        android:autoSizeTextType="none"
        />

    <Button
        android:id="@+id/top_left_button"
        android:layout_width="126dp"
        android:layout_height="wrap_content"
        android:background="@drawable/mafia_buttons_background"
        android:layout_centerVertical="true"
        android:layout_alignParentStart="true"
        android:layout_marginLeft="10dp"
        android:textColor="@color/white"
        android:textAllCaps="false"
        android:rotation="145"
        app:autoSizePresetSizes="@array/auto_size_text_sizes"
        android:autoSizeTextType="none"
        />
    <Button
        android:id="@+id/top_right_button"
        android:layout_width="126dp"
        android:layout_height="wrap_content"
        android:background="@drawable/mafia_buttons_background"
        android:layout_centerVertical="true"
        android:layout_alignParentEnd="true"
        android:layout_marginRight="10dp"
        android:textColor="@color/white"
        android:textAllCaps="false"
        android:rotation="210"
        app:autoSizePresetSizes="@array/auto_size_text_sizes"
        android:autoSizeTextType="none"
        />
</RelativeLayout>
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:id="@+id/buttons_middle_top"
    >
    <Button
        android:id="@+id/middle_top_left_button"
        android:layout_width="126dp"
        android:layout_height="wrap_content"
        android:background="@drawable/mafia_buttons_background"
        android:layout_centerVertical="true"
        android:layout_alignParentStart="true"
        android:layout_marginLeft="-20dp"
        android:textColor="@color/white"
        android:textAllCaps="false"
        android:rotation="90"
        app:autoSizePresetSizes="@array/auto_size_text_sizes"
        android:autoSizeTextType="none"
        />
    <Button
        android:id="@+id/middle_top_right_button"
        android:layout_width="126dp"
        android:layout_height="wrap_content"
        android:background="@drawable/mafia_buttons_background"
        android:layout_centerVertical="true"
        android:layout_alignParentEnd="true"
        android:textColor="@color/white"
        android:textAllCaps="false"
        android:rotation="270"
        app:autoSizePresetSizes="@array/auto_size_text_sizes"
        android:autoSizeTextType="none"
        />
</RelativeLayout>

butttons that I want to move

that is happening after I write marginLeft="300dp"

0 Answers
Related