Gradient a button using transparent in Android?

余生颓废 提交于 2019-12-11 07:04:44

问题


I'm trying to make a button's color to be a gradient from white to transperent to black. My problem is that the button is on top of an image which makes it impossible to use background.

I'm currently using the following code which doesn't build:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners
    android:radius="14dp"
    />
<gradient
    android:angle="45"
    android:centerX="35%"
    android:centerColor="color/transparent"
    android:startColor="#E8E8E8"
    android:endColor="#171717"
    android:type="linear"
    />
<padding
    android:left="0dp"
    android:top="0dp"
    android:right="0dp"
    android:bottom="0dp"
    />
<stroke
    android:width="3dp"
    android:color="#878787"
    />

Error

"error: 'color/transparent' is incompatible with attribute android:centerColor (attr) color. Message{kind=ERROR, text=error: 'color/transparent' is incompatible with attribute android:centerColor (attr) color. "

thanks for the helpers!

|improve this question

来源:https://stackoverflow.com/questions/51954589/gradient-a-button-using-transparent-in-android

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