1

Using Glance beta-01

To handle cornerRadius on Android 12-, we cannot use the GlanceModifier.cornerRadius. So using a custom xml background does the trick, but the Cliping (hiding the content overflowing the radius) only works on the targeted element.

So, is it possible to Clip the content/child of a component when applying a layout with corner Radius on Android S- ?

Example :

Box(modifier = GlanceModifier().background(R.drawable.test)) {
    Text("blabla)
}

with test.xml :

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@color/test" />

    <corners android:radius="@dimen/corner_radius_outside" />
</shape>

would render as something like :

enter image description here

Jscti
  • 14,096
  • 4
  • 62
  • 87

1 Answers1

1

Glance in Android 12+ supports clipping the content via the cornerRadius property. On Android 12- clipping is not supported for remote views, and you should use the padding properties to have your content avoid problem areas.

See : RemoteViewsCompat

  • Argh that + the fact that we cannot "tint" a shape drawable make Glance a huge pain but thanks... – Jscti Jun 27 '23 at 18:45