0

我正在嘗試使用填充漸變色的XML按鈕,圓形形狀。這種顏色需要以編程方式更改。帶有漸變填充的XML圓形Android

這是我想要實現的一個例子。

enter image description here

我嘗試建立這個已經結束了一個漸變背景和紮實的彩色圓圈。而不是漸變圓和透明背景。

我希望能夠使用多於2種顏色或圓形的徑向漸變。任何幫助是極大的讚賞。

回答

0

您可以試着製作Drawable XML。例如

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="circle" > 

    <gradient 
     android:angle="90" 
     android:centerColor="#555994" 
     android:endColor="#b5b6d2" 
     android:startColor="#555994" 
     android:type="linear" />  

</shape> 

根據您的需要安排的角度。

如果你想改變顏色progarmatically然後閱讀本: -

How do I programmatically set the background color gradient on a Custom Title Bar?