2017-07-15 45 views
-1

[在這裏輸入的形象描述] [1]!] [1]想要製作與圖中所示相同的3個圓形,但只有一個stoke不能在圓形形狀xml中工作,我該如何計算出它?

[1]:https://i.stack.imgur.com/4qkRA.png`

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

<item> 
    <shape android:shape="oval"> 
     <solid android:color="#56ECFC"/> 

     <size android:width="400dp" android:height="400dp"/> 

     <stroke android:color="#62DEF5" android:width="30dp"/> 

     <stroke android:color="#4CCCF7" android:width="25dp"/> 

    </shape> 

</item> 

`

+1

我認爲你需要使用層,也許這將有助於[瞭解Android的(https://stackoverflow.com/questions/14436641/understanding-androids-layer-list) – MikeT

回答

1

試試這個使用下面的代碼,你可以畫出4圈

<?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="30dp" 
      android:height="30dp"/> 
    </shape> 
</item> 
<!-- Smaller red circle in front --> 
<item 
    > 
    <shape android:shape="oval"> 
     <!-- transparent stroke = larger_circle_size - smaller_circle_size --> 
     <stroke android:color="@android:color/transparent" 
      android:width="5dp"/> 
     <solid android:color="#f00"/> 
     <size 
      android:width="25dp" 
      android:height="25dp"/> 
    </shape> 
</item> 
<item android:top="2dp" 
    android:right="2dp" 
    android:bottom="2dp" 
    android:left="2dp" 
    > 
    <shape android:shape="oval"> 
     <!-- transparent stroke = larger_circle_size - smaller_circle_size --> 
     <stroke android:color="@android:color/transparent" 
      android:width="5dp"/> 
     <solid android:color="#f000"/> 
     <size 
      android:width="20dp" 
      android:height="20dp"/> 
    </shape> 
</item> 

<item 
    android:top="5dp" 
    android:right="5dp" 
    android:bottom="5dp" 
    android:left="5dp" 
    > 
    <shape android:shape="oval"> 
     <!-- transparent stroke = larger_circle_size - smaller_circle_size --> 
     <stroke android:color="@android:color/transparent" 
      android:width="5dp"/> 
     <solid android:color="#fff0"/> 
     <size 
      android:width="20dp" 
      android:height="20dp"/> 
    </shape> 
</item> 

enter image description here

+1

不需要的筆畫,我猜測。你可以簡化你的drawable。無論如何,+1。這是正確的答案。 –

+1

感謝您的建議@Rotwang –

+1

OP應該接受這個答案。 –

相關問題