-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ShapeableImageView] Support contentPadding #1871
Conversation
so this was closed for what reason? any way to achieve this? |
@jackthebeast It was merged in c4f7de1! Via this repo's kinda-weird merge process. I wish someone had mentioned how to add tests first 😬 but I'll take it 😄 |
@drewhamilton oh, that's weird, I was expecting a clear "merged" status... Anyway, I tried adding the latest alpha to gradle but couldn't find the new method. do you know when it'll become available? |
No, I don't know the release plans or cadence. |
thanks, I'll keep an eye on it |
@drewhamilton Hi, I saw it has been released. I was giving a try:
which correctly adds padding to ic_generic_user. Now, however, ic_generic_user which is a squared vector drawable, is not cut to a circle anymore: example. Any idea what's going on? did you manage to test such a case before? |
This is expected; the shape clips the view itself. Any content that does not intersect the edges of the shape of the view is unaffected. The example you linked was not a consideration when I implemented |
I see, I didn't know that.
Yeah I was already doing something similar so no big deal, just want to simplify it. I will file a feature request and see if anyone else is interested. |
4100115253233934 |
Closes #1489. Adds
contentPadding
APIs to ShapeableImageView. This is achieved by communicating the sum of padding and contentPadding as a single value to the superclass (AppCompatImageView), but tracking them separately in this class. This maintains the existing behavior of ShapeableImageView padding, which pads the background, but takes advantage of the fact that AppCompatImageView does not pad the background.Frankly the internal logic is a nightmare, and hard to wrap my head around even after writing it. But it's the only way I can get it to work while maintaining behavioral compatibility, and it seems to work as expected with some manual testing.
I'm happy to add tests but I can't figure out how they work in this project. Is there something special I need to do to get the IDE to recognize the test sources?