ShapeableImageView support
emartynov opened this issue · comments
Would be cool to have the support of the ShapeableImageView.
Some detailed review of the functionality is here.
I assume that we need another clone of the same class but extending the ShapeableImageView. I think it also should be as different library artefact since not all projects are using material components and don't want to have extra transitive dependency(s).
The first idea was to do
open class TouchImageView constructor(...) : AppCompatImageView(context, attrs, defStyle), Shapeable {
But what to return here ?
override fun setShapeAppearanceModel(shapeAppearanceModel: ShapeAppearanceModel) = Unit
override fun getShapeAppearanceModel(): ShapeAppearanceModel {
return ???
}
But why you don't simply to this ?
class YourShapeView : TouchImageView(...), Shapeable {
...
}
And override draw? Should work.
Give it a try.
Btw, I'm always happy to extend our samples
I understood that already :) And that you like contributions as well :)
I will do it for sure but have some tight schedule with other projects. Some weekend in Feb.
But I still have a feeling that it should be part of the library!
Just to update you quickly - I solved it with next lines:
val outlineProvider = object : ViewOutlineProvider() {
override fun getOutline(view: View, outline: Outline) {
outline.setRoundRect(
0,
0,
view.width,
view.height,
view.resources.getDimension(R.dimen.grid_2)
)
}
}
imagePreview.outlineProvider = outlineProvider
imagePreview.clipToOutline = true
I will contribute to the examples soonish. The issue can be closed I believe.
The example added in #333