0

I made this button that includes an icon.

<Button
    android:id="@+id/buttonId"
    android:drawableLeft="@drawable/icon"
    android:layout_width="270dp"
    android:layout_height="50dp"
    android:background="@drawable/styledbutton"
/>

I made styledbutton.xml that includes the button properties.

styledbutton.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners
    android:radius="0dp" />

<solid
    android:color="#00A9D4" />

<padding
    android:left="0dp"
    android:top="0dp"
    android:right="0dp"
    android:bottom="0dp" />

<size
    android:width="270dp"
    android:height="60dp" />

<stroke
    android:width="2dp"
    android:color="#4F8CDB"/>
</shape>

I create drawable.xml file with these properties, but icon disappeared:

  android:scaleHeight="50%"
  android:scaleWidth="50%

How can I change the size of the icon?

Thanks.

tomss
  • 361
  • 3
  • 13

2 Answers2

0

You can use:

android:scaleHeight="200%"
android:scaleWidth="200%

To reduce just change the percentage:

android:scaleHeight="50%"
android:scaleWidth="50%
S A
  • 827
  • 10
  • 23
0

I resize the icon with these lines of code

    Drawable icon =ContextCompat.getDrawable(getApplicationContext(),R.drawable.icon);
    int WIcon = icon.getIntrinsicWidth();
    int HIcon = icon.getIntrinsicHeight();
    icon.setBounds(0, 0, WIcon/ 10, HIcon/ 10);

It works.

tomss
  • 361
  • 3
  • 13