[英]Gradient not working for Lollipop API 21
Here is the gradient.xml that I am applying on my ImageView.这是我在 ImageView 上应用的gradient.xml。
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="180"
android:endColor="#BF000000"
android:startColor="#00000000"/>
</shape>
I did look at this post - Android Gradient on Lollipop not working.我确实看过这篇文章 - Lollipop 上的 Android Gradient 不起作用。 - API 21 , but my problem is, im not using radial gradient.
- API 21 ,但我的问题是,我没有使用径向渐变。 Hence Im not including gradientRadius in my xml file.
因此,我在我的 xml 文件中不包括 gradientRadius。
Any easy way to fix this?有什么简单的方法可以解决这个问题?
If nothing works them I was thinking of creating a new bitmap, applying a gradient to it and then setting that to the ImageView [I know, its ugly].如果没有任何效果,我正在考虑创建一个新的位图,对其应用渐变,然后将其设置为 ImageView [我知道,它很难看]。
Any help will greatly be appreciated.任何帮助将不胜感激。
I have had the same problem.我曾经也有过一样的问题。
I inserted the "ImageView" into "FrameLayout" and applied the shape.我将“ImageView”插入“FrameLayout”并应用了形状。
For example例如
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="@drawable/gradient">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
I hope that this can help you :)我希望这可以帮助你:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.