How to set the size of a button on android?

2

Could anyone give me a hint how to avoid the following problem?

I have these buttons and I would like to leave them in a fixed size, so they do not rotate when the cell phone is rotated.

I'musingRelativeLayout:

<RelativeLayoutandroid:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    >

Button Settings:

<Button
    android:text="Onde ir?"
    android:layout_width="wrap_content"
    android:id="@+id/button9"
    android:background="@drawable/mapabutton"
    android:textColor="@color/TextoBotao"
    android:textSize="20sp"
    android:layout_height="60dp"
    android:layout_weight="0.5"
    android:fontFamily="sans-serif-condensed"
    tools:fontFamily="serif"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true" />
    
asked by anonymous 19.11.2016 / 22:15

1 answer

4

Just change the "wrap_content" to the desired size or remove the layout_weight

<Button
    android:text="Onde ir?"
    // altere para o tamanho que você quizer
    android:layout_width="300dp"
    android:id="@+id/button9"
    android:background="@drawable/mapabutton"
    android:textColor="@color/TextoBotao"
    android:textSize="20sp"
    android:layout_height="60dp"
    android:layout_weight="0.5" //comentar essa linha também deve resolver
    android:fontFamily="sans-serif-condensed"
    tools:fontFamily="serif"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true" />
    
19.11.2016 / 23:17