GithubHelp home page GithubHelp logo

Comments (9)

sushantpaygude avatar sushantpaygude commented on August 28, 2024 1

I am not able to fit the entire image inside the imageview. Only a portion of the image is displayed inside the imageview. What should be done to fit the entire image inside?

from roundedimageview.

vinc3m1 avatar vinc3m1 commented on August 28, 2024

Huh. I'm not sure what the issue is but you should be using oval=true for that effect, then you don't even need to use corner_radius

from roundedimageview.

marwinxxii avatar marwinxxii commented on August 28, 2024

Thanks! Setting oval=true helped.

But the problem with border width using transformation remains.

Example:
I've used following settings for my ImageView layout_margin=8dp and border_width=16dp for RoundedDrawable.

Enable 'Show layout bounds' in dev options, and run Grid Wichterle app with size of cell 8dp.
Border should be as wide as two cells of grid or twice size of margin, but it's not.

marcus

from roundedimageview.

vinc3m1 avatar vinc3m1 commented on August 28, 2024

Ah, I think I know what's up. When you do fromDrawable there's no way for the function to know what the final imageview size should be, so we add the specified border and width to the original before it resizes, which explains the smaller border sizing.

I don't use Ion personally but from what I remember it's similar to Picasso, so you should try copying some of the code from the Picasso fragment in the example. I think Ion had a similar Transform/Transformation class. Make sure you use the .fit() or equivalent so the bitmap is resized before adding a border. I'm on my phone so can't be more thorough atm. Let me know if that helps.

from roundedimageview.

marwinxxii avatar marwinxxii commented on August 28, 2024

I tried setting drawable bounds both for original and for Rounded, but border stays the same.
Is there any other way how can I do it?

Yes, my Ion transformation builder is nearly the same as for Picasso. I thought there was a problem with it, but unfortunately not.

from roundedimageview.

vinc3m1 avatar vinc3m1 commented on August 28, 2024

Hm, I'm not sure in what order Ion applies its transformations, but basically it needs to apply the border after the resize, otherwise the border size will be wrong. I just tested on the Picasso example and things seem correct, so might be an issue with Ion.

from roundedimageview.

marwinxxii avatar marwinxxii commented on August 28, 2024

Yeah, but as I wrote problem appears without Ion too:

public RoundedDrawable getRoundedDrawable(Resources res, int colorRes, int widthRes, int drawableRes) {
        Drawable original = res.getDrawable(drawableRes);
        //setDrawableDesiredBounds(original);
        RoundedDrawable rounded = (RoundedDrawable) RoundedDrawable.fromDrawable(original);
        //setDrawableDesiredBounds(rounded);
        return rounded
                .setBorderColor(res.getColor(colorRes))
                .setBorderWidth(res.getDimensionPixelSize(widthRes))
                .setOval(true);
    }

Same result when setting and not setting bounds.

from roundedimageview.

vinc3m1 avatar vinc3m1 commented on August 28, 2024

Why are you setting drawable bounds twice? Are they different both times? And what are you doing when you "set desired bounds"? You have to actually resize the bitmap of a BitmapDrawable into a new bitmap, otherwise RoundedDrawable just calls getBitmap and applies border to that...

I guess we could try to use drawable bounds instead of bitmap bounds... But we might not be able to do that efficiently.

from roundedimageview.

vinc3m1 avatar vinc3m1 commented on August 28, 2024

I think there's a misunderstanding of drawable vs bitmap here. RoundedDrawable operates on the source bitmap, not the drawable. So drawable bounds don't matter, and when you set a Drawable into an ImageView, the bounds are set for you anyway. What you want to do is to resize the bitmap. Picasso's .fit() is similar to Ion's resize(w, h) except it automatically resizes to the target view's size.

from roundedimageview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.