2015-05-20 3 views
-2

enter image description hereBorder тень в круг Android

Можно ли предположить, что, как дать тень на границе круга, как на изображении выше.

<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> 

Но я не могу создать тень, как показано выше.

Пожалуйста, помогите мне

Заранее спасибо.

ответ

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> 
Смежные вопросы