3
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:paddingLeft="32dp"
    android:paddingTop="10dp"
    android:paddingRight="0dp"
    android:paddingBottom="10dp">
    <item android:bottom="3dp">
        <bitmap
            android:gravity="center_vertical|left"
            android:src="@drawable/ic_publish_black_24dp" />
        <shape android:shape="rectangle">
            <stroke
                android:width="0dp"
                android:color="#37474f" />
        </shape>
    </item>
</layer-list>  

This is how I call it:

TextView aboutBags = new TextView( mContext );
aboutBags.setText("Compose");
aboutBags.setTextAppearance( R.style.RevStyleHelpAbout );
aboutBags.setBackgroundResource( R.drawable.rev_item_h_border_left );  

I've tried border attributes android:width="22dp" android:height="22dp" all over the XML, but the image doesn't get resized.

How can I resize the bitmap image?

Vielen dank im voraus.

1 Answer 1

7

Using Bitmap may help you. Use like this:

Bitmap nameYourBitmap;

Bitmap resized = Bitmap.createScaledBitmap(nameYourBitmap, newWidth, newHeight, true);

You can also do like this:

resized = Bitmap.createScaledBitmap(nameYourBitmap,(int)(nameYourBitmap.getWidth()*0.8), (int)(nameYourBitmap.getHeight()*0.8), true);

Refer to this: How to resize Image in Android?

For XML, the scale attributes are defined for ScaleDrawables, and they can scale another drawable. Please refer to this developer site: https://developer.android.com/guide/topics/resources/drawable-resource.html#Scale

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for the reply @Animesh Patra. Can I do it inside the XML.
@Program-Me-Rev You are welcome. If my answer was any help, you may accept it for future reference to others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.