Issue
I am trying to create an XML gradient drawable to match this style mentioned in Material Design guidelines
This is my XML code:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="270"
android:centerY="30%"
android:endColor="@android:color/transparent"
android:startColor="#4d000000"
android:type="linear"/>
</shape>
I already tried to set the centerY to 0.3 too, without success. The drawable always look the same in preview.
Can someone tell me what to do to achieve that style? Thanks in advance.
Solution
I don't quite see your mistake. It could be possible that you first have to set the centerColor. Take a look at the docs if you haven't already:
https://developer.android.com/reference/android/graphics/drawable/GradientDrawable.html
But before hustling with a XML drawable that will give you a linear gradient, I suggest you to use Roman Nuriks attempt to this problem. See more here: https://plus.google.com/+RomanNurik/posts/2QvHVFWrHZf He solved the problem by using a Java implementation of a Drawable. Works as any other drawable.
Answered By - Jonas Drotleff
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.