We all know that we can load a drawable formed using <shape> or <layer> tag as a background using view.setBackground(drawable) in our traditional Android System.
Is there a way we can set these drawables as a background to a composable in Compose?
I know we can set background to a composable using a shape or brush but how can we do for the below case? Can't we load a xml which is declared below(normally lot of industry projects use)in compose?
Say i have an xml drawable named cta_3d.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="@color/purple_light" />
<corners android:radius="8dp" />
</shape>
</item>
<item android:bottom="2dp">
<shape>
<solid android:color="@color/white" />
<stroke
android:width="0.5dp"
android:color="@color/purple" />
<corners android:radius="8dp" />
</shape>
</item>
</layer-list>
I want to set it to the background of the text composable
Text(
text = "This is a text composable",
modifier = modifier
.padding(16.dp),
fontSize = 24.sp,
color = Color.Black
)
Tried using paint but it gave error whose reason is written below Does anyone know how can we do it? Is there a way to load these as painterResource only loads vector or image assests only.
Tried painterResource but it can load only vector and images.