layer list drawable image
The above was drawn using layer-list.
<layer-list>
<item
android:width="100dp"
android:height="30dp">
<shape android:shape="rectangle">
<stroke
android:width="1px"
android:color="#00000000" />
<solid android:color="#00000000" />
</shape>
</item>
<item
android:width="2dp"
android:bottom="1dp"
android:top="20dp">
<shape android:shape="rectangle">
<solid android:color="@color/tdTeal" />
</shape>
</item>
<item
android:width="2dp"
android:bottom="20dp"
android:top="0dp">
<shape android:shape="rectangle">
<solid android:color="@color/tdTeal" />
</shape>
</item>
<item
android:width="2dp"
android:bottom="0dp"
android:gravity="right"
android:top="20dp">
<shape android:shape="rectangle">
<solid android:color="@color/tdTeal" />
</shape>
</item>
<item
android:width="2dp"
android:bottom="20dp"
android:gravity="right"
android:top="0dp">
<shape android:shape="rectangle">
<solid android:color="@color/tdTeal" />
</shape>
</item>
<item
android:height="2dp"
android:gravity="top"
android:left="0dp"
android:right="90dp"
android:top="-1dp">
<shape android:shape="rectangle">
<solid android:color="@color/tdTeal" />
</shape>
</item>
<item
android:height="2dp"
android:gravity="top"
android:left="90dp"
android:right="0dp"
android:top="-1dp">
<shape android:shape="rectangle">
<solid android:color="@color/tdTeal" />
</shape>
</item>
<item
android:height="2dp"
android:gravity="bottom"
android:left="0dp"
android:right="90dp">
<shape android:shape="rectangle">
<solid android:color="@color/tdTeal" />
</shape>
</item>
<item
android:height="2dp"
android:gravity="bottom"
android:left="90dp"
android:right="0dp">
<shape android:shape="rectangle">
<solid android:color="@color/tdTeal" />
</shape>
</item>
</layer-list>
In the past, we could set buttons to have a custom background such as the above and have text or Icons within the rectangle. How would one recreate the above in Jetpack Compose? Ultimately I want the below button. Any help would be appreciated.
Goal
If the above is too complicated, can we use both Compose and drawable together? I’ve tried the following
Box(
modifier = modifier.size(250.dp).paint(
painter = painterResource(id = R.drawable.border_box)
)
)
But Android Studio is spitting out rendering issues.
Loki Poo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.