android gradient with 4 params

怎甘沉沦 提交于 2019-12-25 02:27:07

问题


How can I make a gradient like this in xml

I can not do it with just these params

startColor=""
centerColor=""
endColor=""

any ideas ?


回答1:


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

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

    <corners 
        android:radius="0dp"/>

</shape>



回答2:


if you want to draw it through shape you have to do work with layer-list. You can think about it like two rectangles and every rectangle has its own gradient color.



来源:https://stackoverflow.com/questions/21284812/android-gradient-with-4-params

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!