如何使一个Android半透明的主题有点暗? [英] How to make an Android Translucent theme a little darker?

查看:149
本文介绍了如何使一个Android半透明的主题有点暗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用在我的Andr​​oid清单文件以下的Andr​​oid主题:

I use following Android theme in my Android manifest file:

android:theme="@android:style/Theme.Translucent"

这是一个半透明的主题,以及它有一个半透明的背景,但我需要使这个主题的背景的小更暗,或更换一个到另一个(半透明背景,但它应该是稍微较暗)。请告诉我,我该怎么办呢?

It's a translucent theme, and it has a translucent background, but I need to make the background of this theme a small darker, or replace the one to another (with translucent background, but it should be a little darker). Please, tell me, how can I do it?

推荐答案

直接从Android文档:的 http://developer.android.com/guide/topics/ui/themes.html

Straight from android documentation: http://developer.android.com/guide/topics/ui/themes.html

或者,如果你希望背景是透明的,用半透明的主题:

Or if you want the background to be transparent, use the Translucent theme:

<activity android:theme="@android:style/Theme.Translucent">

如果你喜欢的主题,但想调整它,只需添加主题,自定义主题的父。例如,您可以修改传统光源主题中使用自己的颜色是这样的:

If you like a theme, but want to tweak it, just add the theme as the parent of your custom theme. For example, you can modify the traditional light theme to use your own color like this:

<color name="custom_theme_color">#b0b0ff</color>
<style name="CustomTheme" parent="android:Theme.Light">
<item name="android:windowBackground">@color/custom_theme_color</item>
<item name="android:colorBackground">@color/custom_theme_color</item>
</style>

(注意颜色需要提供如下独立的资源,因为在android:windowBackground属性只支持到另一个资源的参考;不像机器人:colorBackground,它不能被赋予一种颜色的文字)

(Note that the color needs to supplied as a separate resource here because the android:windowBackground attribute only supports a reference to another resource; unlike android:colorBackground, it can not be given a color literal.)

现在使用CustomTheme代替Theme.Light Android清单内:

Now use CustomTheme instead of Theme.Light inside the Android Manifest:

<activity android:theme="@style/CustomTheme">

这篇关于如何使一个Android半透明的主题有点暗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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