I am trying to build a simple home screen widget with multiple clocks(different regions). Design wise, I want to use a CardView (e.g. the google search bar) as the root layout element, but since its not supported in widgets, how can I replicate it? Can I use its parent class i.e. Frame Layout in some way?
You can use a supported view class and set the background drawable to the card_drawable defined here:
https://gist.github.com/MarsVard/8297976
For example, to a LinearLayout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/card_drawable"
>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Test"
/>
</LinearLayout>
</LinearLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With