android-shape
How to draw a circle inside a circle using Android xml shapes?
The only way I’ve gotten this to work is to define a transparent stroke for the inner (i.e., top) circle that’s the difference between the size of the larger and smaller circle. For example, this: <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <!– Larger blue circle in back –> <item> <shape android:shape=”oval”> <solid android:color=”#00f”/> <size android:width=”15dp” android:height=”15dp”/> … Read more
What does top, left, right and bottom mean in Android Rect object
This image will explain you in detail: left The X coordinate of the left side of the rectangle top The Y coordinate of the top of the rectangle right The X coordinate of the right side of the rectangle bottom The Y coordinate of the bottom of the rectangle
angle attribute in android gradient
Gradient basically represents the variation in space(in a direction) of any quantity. With color it represents the variation of color intensity in a direction represented by angle. Here are some diagrams to represent this concept: Here the figure shows the color variation in horizontal direction (angle is set 0).XML code: <shape xmlns:android=”http://schemas.android.com/apk/res/android”> <gradient android:startColor=”#000000″ android:angle=”0″/> … Read more
How to make a shape with left-top round rounded corner and left-bottom rounded corner?
It looks like a bug http://code.google.com/p/android/issues/detail?id=939. Finally I have to write something like this: <stroke android:width=”3dp” android:color=”#555555″ /> <padding android:left=”1dp” android:top=”1dp” android:right=”1dp” android:bottom=”1dp” /> <corners android:radius=”1dp” android:bottomRightRadius=”2dp” android:bottomLeftRadius=”0dp” android:topLeftRadius=”2dp” android:topRightRadius=”0dp”/> I have to specify android:bottomRightRadius=”2dp” for left-bottom rounded corner (another bug here).
Open-sided Android stroke?
I achieved a good solution with this one: <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <!– This is the line –> <item android:top=”-1dp” android:right=”-1dp” android:left=”-1dp”> <shape> <solid android:color=”@android:color/transparent” /> <stroke android:width=”1dp” android:color=”#ffffff” /> </shape> </item> </layer-list> This works well in case you need a transparent background but still an open stroke color (In my case I only … Read more
How to make a view with rounded corners?
Another approach is to make a custom layout class like the one below. This layout first draws its contents to an offscreen bitmap, masks the offscreen bitmap with a rounded rect and then draws the offscreen bitmap on the actual canvas. I tried it and it seems to work (at least for my simple testcase). … Read more