本文介绍了Android渐变永远无法正常工作(始终绑定)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图添加(径向)渐变作为背景(在Android 4.0中),无论是作为背景图像还是以编程方式添加,但是它们都不起作用.我只能在模拟器中对其进行测试,但我猜它在4.0设备上是相同的.
I tried to add a (radial) gradient as background (in Android 4.0), either as background image or programmatically but none of them never works. I can only test it in emulator, but I guess it's the same on a 4.0 device.
这些解决方案不起作用:
These solutions don't work:
- 放置在原始文件夹中.(禁用Android资源/图像/png优化)
- 使具有抖动和反锯齿的代理xml为真,并将png的opacy保存为99%.( android:dither ="true"不会抖动,这是怎么回事?)
- 在onAttachedToWindow上覆盖( Android:使用线性渐变作为背景看起来是带条纹的)
- 移动到hdpi文件夹( Gingerbread上的渐变)
- 以编程方式进行渐变( http://crazygui.wordpress.com/2010/09/05/high-quality-radial-gradient-in-android/)
我想我还尝试了一些尝试,但是也许有人对如何建立工作渐变作为背景有一个想法?
I guess I tried some more things but maybe someone has an idea how to build a working gradient as background?
我当前的代码如下:
<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>
和background_image.xml
and background_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" />
推荐答案
显然,它只是模拟器.在真实的设备上看起来不错.
Obviously it's just the emulator. On a real device it looks good.
这篇关于Android渐变永远无法正常工作(始终绑定)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!