Circle Android

时间:2015-05-20 07:12:13

标签: android

enter image description here

任何人都可以建议如何像上面的图像一样在圆的边界上给阴影。

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="1.9"
android:useLevel="false" >
<solid android:color="#33FFFFFF" />

<stroke
    android:width="5dp"
    android:color="@android:color/white" /></shape>

但是我无法在Image上面创建阴影。

请帮帮我

提前致谢。

1 个答案:

答案 0 :(得分:0)

尝试这样的事情:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- "background shadow" -->
<item>
    <shape android:shape="circle" >
        <solid android:color="#000000" />

        <corners android:radius="15dp" />
    </shape>
</item>
<!-- background color -->
<item
    android:bottom="3px"
    android:left="3px"
    android:right="3px"
    android:top="3px">
    <shape android:shape="circle" >
        <solid android:color="#cc2b2b" />
    </shape>
</item>
<!-- over left shadow -->
<item>
    <shape android:shape="circle" >
        <gradient
            android:angle="180"
            android:centerColor="#00FF0000"
            android:centerX="0.9"
            android:endColor="#99000000"
            android:startColor="#00FF0000" />

    </shape>
</item>
<!-- over right shadow -->
<item>
    <shape android:shape="circle" >
        <gradient
            android:angle="360"
            android:centerColor="#00FF0000"
            android:centerX="0.9"
            android:endColor="#99000000"
            android:startColor="#00FF0000" />
    </shape>
</item>
<!-- over top shadow -->
<item>
    <shape android:shape="circle" >
        <gradient
            android:angle="-90"
            android:centerColor="#00FF0000"
            android:centerY="0.9"
            android:endColor="#00FF0000"
            android:startColor="#99000000"
            android:type="linear" />
    </shape>
</item>
<!-- over bottom shadow -->
<item>
    <shape android:shape="circle" >
        <gradient
            android:angle="90"
            android:centerColor="#00FF0000"
            android:centerY="0.9"
            android:endColor="#00FF0000"
            android:startColor="#99000000"
            android:type="linear" />
    </shape>
</item>
</layer-list>

或类似的东西:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:drawable="@drawable/shadow"
    android:id="@id/shadow"
    android:top="dimension"
    android:right="dimension"
    android:bottom="dimension"
    android:left="dimension" />
<item
    android:drawable="@drawable/hh"
    android:id="@id/ring"
    android:top="dimension"
    android:right="dimension"
    android:bottom="dimension"
    android:left="dimension" />
</layer-list>

阴影就像

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="circle">
<gradient
  android:centerColor="@android:color/darker_gray" 
  android:endColor="@android:color/darker_gray" 
  android:startColor="@android:color/darker_gray"  />
<size  android:height="140dp"
    android:width="120dp" />
</shape>