I have the following button:
<Button
android:id="@+id/buttonok"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/back_no_save"
android:text="OK" />
Its appearence is:
How can I scale down my drawable and show a small arrow?
The background-size CSS property lets you resize the background image of an element, overriding the default behavior of tiling the image at its full size by specifying the width and/or height of the image. By doing so, you can scale the image upward or downward as desired.
Using CSS, you can set the background-size property for the image to fit the screen (viewport). The background-size property has a value of cover . It instructs browsers to automatically scale the width and height of a responsive background image to be the same or bigger than the viewport.
Type background-color: in the quotation marks after "style=". This element is used to change the background color of the button. Type a color name or hexadecimal code after "background-color:". You can type name of a color (i.e, blue) or a hexadecimal color.
You could use an ImageButton
and try android:scaleType
ImageView.ScaleType
I don't hink you can from xml. There's no xml attribute that can do scaling for buttons. You can do it programatically though, in the following way :
Bitmap originalBitmap= BitmapFactory.decodeResource(getResources(), R.drawable.icon);
Bitmap scaledBitmap=Bitmap.createScaledBitmap(originalBitmap, newWidth, newHeight, true);
txt.setBackgroundDrawable(new BitmapDrawable(bit));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With