GithubHelp home page GithubHelp logo

Comments (13)

vinc3m1 avatar vinc3m1 commented on May 18, 2024

If you don't mind testing, please update your dependencies to use the snapshot and let me know how it performs:

repositories {
    mavenCentral()
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots"
    }
}
dependencies {
    compile 'com.makeramen:roundedimageview:1.2.4-SNAPSHOT'
}

from roundedimageview.

hamidp avatar hamidp commented on May 18, 2024

Will try it out.

I actually ended up implementing a RoundedColorDrawable that works very well that I had planned to PR

from roundedimageview.

thevery avatar thevery commented on May 18, 2024

doesn't work for me with custom drawable (it seems that wrong canvas size (1x1) is passed)

from roundedimageview.

vinc3m1 avatar vinc3m1 commented on May 18, 2024

what custom drawable are you passing in?

from roundedimageview.

thevery avatar thevery commented on May 18, 2024

nothing very special, just public class AvatarDrawable extends Drawable with it's own onDraw implementation with some drawText's.

from roundedimageview.

vinc3m1 avatar vinc3m1 commented on May 18, 2024

Ah, I would do one of 2 things:

  • Return a value > 1 in getInstrinsicHeight() and getIntrinsicWidth(). This method would fix the canvas size of 1 issue, but whatever size you return will be the size of the bitmap that gets drawn, and later stretched to fit (probably not what you want).
  • Instead I recommend extending RoundedImageDrawable instead of Drawable and simply doing your text drawing after calling super.onDraw

from roundedimageview.

thevery avatar thevery commented on May 18, 2024

first one is obviously not a solution, neither is the second one - I must call super(null); in constructor and this causes NPE.
NB: I override draw, not onDraw in Drawable (later one is for View).

from roundedimageview.

vinc3m1 avatar vinc3m1 commented on May 18, 2024

why must you call super(null)? you can just let RoundedDrawable handle the bitmap part of your avatar, so call super.draw(canvas) and just use super.setBitmap() (or res or drawable).

Otherwise if you're already doing all the custom drawing just do canvas.drawCircle(cx, cy, r, bitmapPaint) and you don't even need this library...

from roundedimageview.

thevery avatar thevery commented on May 18, 2024

I don't have any bitmap part of avatar.
All custom drawing (and especially round cropping) is already done, but using some library will make my code much more simple.

from roundedimageview.

vinc3m1 avatar vinc3m1 commented on May 18, 2024

This library is a convenience for people who don't want to write custom views and specifically optimizes for the case of rounded bitmaps. It's not meant to augment custom views/drawables well since the behavior most custom views is, well... very custom. It's impossible to predict how all custom views will work and accommodate for all of them.

Like I said, if your view has extra behavior on top of being rounded, I suggest extending or forking this library to reuse the code, otherwise supporting arbitrary custom drawables and views is not the aim of this library.

from roundedimageview.

hamidp avatar hamidp commented on May 18, 2024

Snapshot build does round the corners for us on color drawables. Once it's officially released we'll switch to using it.

Thanks!

from roundedimageview.

vinc3m1 avatar vinc3m1 commented on May 18, 2024

Cool, there are still some bugs I can't seem to hunt down (see example app), but if it works for most cases I'll push up the new version now.

from roundedimageview.

thevery avatar thevery commented on May 18, 2024

@vinc3m1 I fully agree on your points about limited features support and forking, the only problem is that you realize limitations only after the first run and spend useless efforts on adding library to your project.

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.