Open yvolk opened 4 years ago
As Reboot Myth suggested "With the new phones having rounded screens, can the widget also support rounded rectangles?"
I found this discussion https://stackoverflow.com/questions/26074784/how-to-make-a-view-with-rounded-corners and it looks like we can achieve this using the CardView at the top of the Widget's views hierarchy: https://developer.android.com/jetpack/androidx/releases/cardview
The question remains how to make this rounding optional without additional widget redraws...
And here https://medium.com/@iamsadesh/android-ui-creating-a-layout-rounded-only-in-the-top-d60514ccab77 the author suggests to set outline for the parent view and then .setClipToOutline(true) on it...
val image = findViewById<ImageView>(R.id.image) val curveRadius = 20F if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { image.outlineProvider = object : ViewOutlineProvider() { @RequiresApi(Build.VERSION_CODES.LOLLIPOP) override fun getOutline(view: View?, outline: Outline?) { outline?.setRoundRect(0, 0, view!!.width, (view.height+curveRadius).toInt(), curveRadius) } } image.clipToOutline = true }
Agree with this suggeation, rounded corners would be a super face lift.
As Reboot Myth suggested "With the new phones having rounded screens, can the widget also support rounded rectangles?"
I found this discussion https://stackoverflow.com/questions/26074784/how-to-make-a-view-with-rounded-corners and it looks like we can achieve this using the CardView at the top of the Widget's views hierarchy: https://developer.android.com/jetpack/androidx/releases/cardview
The question remains how to make this rounding optional without additional widget redraws...
And here https://medium.com/@iamsadesh/android-ui-creating-a-layout-rounded-only-in-the-top-d60514ccab77 the author suggests to set outline for the parent view and then .setClipToOutline(true) on it...