user0918j9
user0918j9

Reputation: 23

How do I make my Android button smaller?

Here is my current code.

<Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Weather"
        android:textColor="@color/colorDark"
        style="@style/XM.ActionBar.ButtonSecondary"
        android:drawableTop="@mipmap/ic_weather_sunny" />

How do I make the entire button smaller in size? It is in a LinearLayout.

Thanks Kevin

Upvotes: 2

Views: 3038

Answers (3)

Andy
Andy

Reputation: 469

You can set the width and height manually instead of using wrap_content if you want smaller button size. But doing so would probably make your button too small to contain the text inside. So you probably would like to control the font size

<Button android:layout_width="100dp"
    android:layout_height="100dp"
    android:text="Weather"
    android:textSize="10sp"
    android:textColor="@color/colorDark"
    style="@style/XM.ActionBar.ButtonSecondary"
    android:drawableTop="@mipmap/ic_weather_sunny"/>

Edited: textSize to sp thanks @MinnuKaAnae

Upvotes: 3

MinnuKaAnae
MinnuKaAnae

Reputation: 1646

Change width and height to as per your requirement

  <Button
    android:layout_width="80dp"
    android:layout_height="40dp"
    android:text="Weather"
    android:textColor="@color/colorDark"
    style="@style/XM.ActionBar.ButtonSecondary"
    android:drawableTop="@mipmap/ic_weather_sunny" />

Upvotes: 0

Em&#237;lio Fonseca
Em&#237;lio Fonseca

Reputation: 92

Try setting width and heigth to somthing like 40dp each. If it does not work, remove the theme applied :D

Upvotes: 0

Related Questions