I just created a red circle using android shapes:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:innerRadiusRatio="4" android:shape="ring" android:thicknessRatio="9" android:useLevel="false" > <solid android:color="#FF0000" /> <size android:height="48dip" android:width="48dip" /> </shape>
This is really cool, but I cannot set the background color of the circle to my color. I tried android:background="#FFFFFF"
but it always appear to be black in my layout. How can I set the background of the above shape?
This round_corners.xml can be used to make a Circle, rounded corner rectangle, and and oval button. A circle, since the width and height of this view is 60dp, and the radius defined in the round_corners shape is half the length of the view’s width and height, so it makes this view a circle.
The background-image property specifies an image to use as the background of an element. By default, the image is repeated so it covers the entire element. This example shows a bad combination of text and background image. The text is hardly readable: Note: When using a background image, use an image that does not disturb the text.
CSS background-color. The background-color property specifies the background color of an element. Example. The background color of a page is set like this: body { background-color: lightblue; } Try it Yourself » With CSS, a color is most often specified ...
The background-repeat property allows you to tile the background image into a pattern. SVGs are a transparent image format and if the SVG elements do not cover the entire viewBox, the background color will be visible behind your SVG. The background origin determines the boundary of the background’s container.
I think a layer-list
might help you:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle" > <solid android:color="#ffffff" /> </shape> </item> <item> <shape android:innerRadiusRatio="4" android:shape="ring" android:thicknessRatio="9" android:useLevel="false" > <solid android:color="#FF0000" /> <size android:height="48dip" android:width="48dip" /> </shape> </item> </layer-list>
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