windowBackground Android中6(棉花糖) [英] windowBackground in Android 6 (Marshmallow)

查看:664
本文介绍了windowBackground Android中6(棉花糖)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经定义了一个基本样式为我用下面的元素应用程序:

I have defined a base style for my application with the following element:

<item name="android:windowBackground">@color/window_background</item>

其中已设置背景色为我所有的活动,直到我测试了我的应用程序在Android 6,所有的背景都是白色的。背景是仍然在运行pre-棉花糖设备彩色/ window_background。

Which has set the background color for all my activities fine until I tested my app on Android 6 where all backgrounds are white. The backgrounds are still color/window_background on devices running pre-marshmallow.

任何人都知道如何使这项工作(或为什么它不工作)在Android 6?

Anyone know how to make this work (or why it is not working) on Android 6?

编辑与一些更多的信息: 我针对API 22,我还没有从previous版本改变任何东西或升级API,只是在Android上运行6改变的背景。

Edit with some more info: I am targeting API 22, I have not changed anything from previous version or upgraded the API, just running on Android 6 changes the background.

推荐答案

我还没有发现任何具体的棉花糖,将导致此。所以我的建议是:

I haven't found anything specific for Marshmallow that would cause this. So the suggestions I have are:

更改背景颜色资源到绘制形状资源。

Changing the background color resource to a drawable shape resource.

从:

<item name="android:windowBackground">@color/window_background</item>

要:

<item name="android:windowBackground">@drawable/window_background</item>

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="@color/window_background"/>
</shape>

如果你没有检查你所有意见的不透明度:

In case you haven't checked the opacity of all your views:

请确保您的windowBackground实际上是大部分的背景   你的活动(尤其是在滚动的部分,其中透支   是最重要的,以避免),去除不透明视图背景   在可能的情况

Make sure your windowBackground actually is the background of most of your Activity (particularly over scrollable sections where overdraw is the most important to avoid), removing opaque view backgrounds where possible.

请使用空你windowBackground为你工作,而不是

Make your windowBackground work for you instead of using null

我认为这是有趣的,看看怎样的背景层设置precedence。我不知道,如果你设置任何视图背景或您如何设置您的应用程序,但是这是值得一读。

I thought this was interesting, to see the precedence of how background layers are set. I am not sure if you are setting any view backgrounds or how you have set up your app, but this is worth a read.

背景几层组成,从后到前:

Backgrounds consist of several layers, from back to front:

      
  • 主题的背景绘制对象
  •   
  • 纯色(通过setColor设置(INT))
  •   
  • 两位可绘,previous和电流(通过setBitmap(位图)setDrawable(抽出式)设置),这可能是转型期
  •   
  • the background Drawable of the theme
  • a solid color (set via setColor(int))
  • two Drawables, previous and current (set via setBitmap(Bitmap) or setDrawable(Drawable)), which may be in transition

<一个href="https://developer.android.com/reference/android/support/v17/leanback/app/BackgroundManager.html"相对=nofollow> BackgroundManager

我找不到,如果有与主题棉花糖,或者元素的顺序有差别,似乎并没有出现根本性的变化,我找不到任何错误这一点。

I can't find if there is a difference with the themes in Marshmallow, or the order of elements, it seems there has been no fundamental changes and I can find no bug for this.

我希望这可以帮助,让我知道,我可以再看一看。

如果这没有帮助它可能是值得张贴相关的问题更多一些code。干杯。

If this doesn't help it may be worth posting some more code relevant to the problem. Cheers.

这篇关于windowBackground Android中6(棉花糖)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆