Android Drawable Shape Ring at a lower API level

I have defined a simple ring suitable for use as a button background. Here is how I do it:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="ring" android:innerRadius="20dp" android:thickness="1dp" android:useLevel ="false" > <solid android:color="@color/lines" /> /> </shape> 

I use it in relative layout, for example:

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" android:padding="30dip" android:orientation="vertical"> <TextView android:text="@string/start_game" android:layout_height="wrap_content" android:layout_width="wrap_content" /> <Button android:id="@+id/start" android:layout_height="wrap_content" android:layout_width="wrap_content" android:background="@layout/round_button" android:layout_alignParentBottom="true" /> </RelativeLayout> 

Where round_button is my xml file where I defined the ring. This gives me great results when I set the minimum sdk level to 11 or higher. But the problem is that when I try to change it to a level below the api, say 3, the ring does not appear! What am I missing here?

+4
source share
1 answer

I came across something similar. I fixed it by setting the useLevel attribute to false in the figure, for example:

 <shape android:shape="ring" android:thickness="@dimen/indicatorcircle_thickness" android:useLevel="false"> <size android:width="@dimen/indicatorcircle_size" android:height="@dimen/indicatorcircle_size"/> <solid android:color="@color/white"/> </shape> 
0
source

Source: https://habr.com/ru/post/1402107/


All Articles