我希望我的图标具有渐变颜色。我找到了如何制作渐变背景的方法,但这对我的情况没有帮助。
这是我的图标代码:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:strokeColor="#000"
android:fillColor="#000"
android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"/>
<path
android:fillColor="#FF000000"
android:pathData="M9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2L9,2zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z"/>
</vector>
到目前为止,我已经做了以下工作来获得渐变文本:
mPicGallery = (Button) getView().findViewById(R.id.get_picture_gallery);
Shader textShader_8 = new LinearGradient(200, 20, 50, 10, new int[]{Color.parseColor("#01579b"),Color.parseColor("#006064")}, new float[]{0, 1}, Shader.TileMode.CLAMP);
mPicGallery.getPaint().setShader(textShader_8);
这很不规范,但我没有找到更好的方法。
所以我的问题是:如何用渐变色制作图标。
以下是我想要的示例: