android 背景梯度漸變 原

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

    <gradient
        android:angle="270"
        android:centerColor="#00FF00"
        android:centerX="50%"
        android:centerY="50%"
        android:endColor="#ffffff"
        android:startColor="#FF7700"
        android:type="linear" />

</shape>

再你的res/drawable/文件夾下,創建bg_gradient_orange_green_white.xml文件,內容如上

並將該文件設置你使用的空間的background屬性即可

這個是三色效果,通過設置角度270,從上到下,由橙變綠再變白

如果只需要兩色的話,只需要把帶center的屬性去掉即可,xy的值是比例,自己測試就好

參考:http://angrytools.com/android/button/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章