Closed amaslanka closed 4 years ago
Hello, thanks for the PR!
I'll hopefully spend some time checking this out in more detail to fully understand it. But, do you mind adding a "unit test" to demonstrate this feature? Essentially, just add another item to the sample activity that shows it working.
In addition, I would recommend testing the feature on a few different Android versions (I usually do API19, API21, and API26 or 27) just to be sure.
Hi!
Take a look at the example which I provided in the sample activity. It's tested on different API versions.
Can you explain why you took VectorDrawable
and converted it into a BitmapDrawable
?
I changed the code to just return a VectorDrawable
and the sample works out to be the same. Tinting seems to be working fine with just the VectorDrawable
. (Tested on API 19 & 21)
The bug appears on API 28. The selectedDrawableTint
of SegmentedButton
is always applied to its drawable if the drawable type is VectorDrawable
. Take a look at the screenshot.
After converting VectorDrawable
to BitmapDrawable
the tint is working fine on API 28.
On lower API versions the bug doesn't appear at all.
Wow, what a crazy bug. It's gone on API 29, so I made adjustments to the code to only convert from vector to bitmap in API 28. My thought process is that keeping the vector as a vector drawable is more efficient (in terms of memory) than converting to a bitmap. Although, in the end, the performance/memory differences is likely minimal.
Everything looks good! I'll add the new sample GIF and release a new version. Thanks
Added checking drawable type in SegmentedButton. If the drawable is Vector, it will be converted into a bitmap. This allows to handle drawable tint/selected tint properly.