Android gradient从不工作(总是绑定)
我尝试添加一个(径向)渐变作为背景(在Android 4.0中),或者作为背景图像,或者以编程方式,但它们都不起作用。我只能在emulator中测试它,但我想在4.0设备上也是一样的 这些解决方案不起作用:Android gradient从不工作(总是绑定),android,gradient,radial-gradients,Android,Gradient,Radial Gradients,我尝试添加一个(径向)渐变作为背景(在Android 4.0中),或者作为背景图像,或者以编程方式,但它们都不起作用。我只能在emulator中测试它,但我想在4.0设备上也是一样的 这些解决方案不起作用: 放置在原始文件夹中。 () 使抖动和抗锯齿的代理xml为真,并将png的不透明度降低到99%。() 重写onAttachedToWindow() 正在移动到hdpi文件夹() 以编程方式生成渐变() 我想我尝试了更多的东西,但也许有人知道如何建立一个工作梯度作为背景 我当前的代码如下所示
- 放置在原始文件夹中。 ()
- 使抖动和抗锯齿的代理xml为真,并将png的不透明度降低到99%。()
- 重写onAttachedToWindow()
- 正在移动到hdpi文件夹()
- 以编程方式生成渐变()
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SplashScreen">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/desc_string"
android:scaleType="centerCrop"
android:src="@drawable/background_image" />
</RelativeLayout>
和背景_image.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background_image"
android:antialias="true"
android:dither="true"
android:src="@drawable/bg_portrait" />
试试这个链接
覆盖绘制功能,使用画布对象绘制圆显然,它只是一个模拟器。在真正的设备上,它看起来不错。在本例中,它仍然是带状的。此外,我甚至无法创建径向渐变,因为
java.lang.IllegalArgumentException:radius必须大于0
,尽管我已经设置了半径(示例底部)