alexzhirkevich / custom-qr-generator

Android library for creating QR codes with logo, custom shapes, colors, background image. Powered by ZXing
MIT License
173 stars 18 forks source link

Need option for Padding/Margin for QrVectorBackground Image #25

Closed hardikbhalodi closed 1 year ago

hardikbhalodi commented 1 year ago

Right now lib has feature options.setPadding() which apply only to the QrCodeDrawable but when set background image it apply to whole area. Can we have that feature so we can give desire padding/margin to the background image too?

alexzhirkevich commented 1 year ago

You can wrap your background image in InsetDrawable

hardikbhalodi commented 1 year ago

i tried that way but its not applying! background set to whole while i have padding for qr code and inset for background drawable.

alexzhirkevich commented 1 year ago

Is that the result you want?

image ```kotlin createQrVectorOptions { background { drawable = ContextCompat.getDrawable( this@MainActivity, R.drawable.frame ) } } ```
image ```kotlin createQrVectorOptions { background { drawable = InsetDrawable( ContextCompat.getDrawable( this@MainActivity, R.drawable.frame)!!, .1f ) } } ```
hardikbhalodi commented 1 year ago

Screenshot_20230403_184625 Screenshot_20230403_184532

Its applying like first image, i wanted to achieve like second image which has options.setPadding(0.15) (i did gray background just to explain)

alexzhirkevich commented 1 year ago

Why don't you just set code padding to 0 and add padding to the ImageView.

Btw, this drawable definitely works for the 2nd case

InsetDrawable(yourBackgroundImage, 0.15f)
hardikbhalodi commented 1 year ago

I could add padding to the ImageView but it will apply to the view only and later when creating a drawable the padding will not be there in the drawable itself. Thanks for your reply and suggestions. I will check it out.

On Mon, Apr 3, 2023 at 9:46 PM Alexander Zhirkevich < @.***> wrote:

Why don't you just set code padding to 0 and add padding to the ImageView

— Reply to this email directly, view it on GitHub https://github.com/alexzhirkevich/custom-qr-generator/issues/25#issuecomment-1494613796, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFYHHUA5ZHI6Z7QON7QB4LW7LZV5ANCNFSM6AAAAAAWLO7DZA . You are receiving this because you authored the thread.Message ID: @.***>