본문 바로가기

안드로이드

Draw circle in android xml file.


http://stackoverflow.com/questions/14209725/how-can-i-draw-circle-in-android-xml-file



You need to create a shape drawable in the drawable folder that looks something like:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" >
    <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF"
        android:angle="270"/>
</shape>

(For this example I have saved the drawable as circle.xml and it will have a gradient fill)

Then in your layout you need to define a view and set the shape as the background:

<View android:layout_width="50dp"
    android:layout_height="50dp"
    android:background="@drawable/circle"/>

The View defines the size and dimensions of the shape.




'안드로이드' 카테고리의 다른 글

android app icon size  (0) 2014.04.16
transparent color in android  (0) 2014.04.13
Android: transparent color 만들기  (0) 2013.09.30
Drop Shadow LinearLayout  (0) 2013.09.03
25 Free Color Tools, Apps and Palette Generators  (0) 2013.08.11