Android: How to make Circle through xml which look

2019-07-10 02:44发布

I am trying to make a circle using xml with a halo. The halo would be like it starts with say green color in the center, the greenish color keeps fading and finally at the edges it becomes transparent.

How to go about it?

I am trying to use following:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <gradient   android:centerColor="@drawable/light_green" android:gradientRadius="250" android:type="radial"
         android:endColor="@android:color/transparent"
        android:angle="270"/>
</shape>

Still not able to get the desired effect. Any lead would be helpful.

1条回答
甜甜的少女心
2楼-- · 2019-07-10 03:00

Try this:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval" >

    <gradient
        android:angle="270"
        android:centerColor="#88FF0000"
        android:centerX="50%p"
        android:centerY="50%p"
        android:endColor="#00FF0000"
        android:gradientRadius="50%p"
        android:startColor="#FFFF0000"
        android:type="radial" />
       <size
           android:height="80dp"
           android:width="80dp" />

</shape>

Change color code and change centerColor's alpha code as per your requirement

查看更多
登录 后发表回答