如何将多个主题的属性添加到Android清单相同的活动? [英] How to add multiple theme attributes to the same activity on Android Manifest?

查看:113
本文介绍了如何将多个主题的属性添加到Android清单相同的活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个活动的Andr​​oid清单,我想申请样式:

I have an android manifest with an activity that I want to apply to styles to:

 <activity android:label="@string/app_name" android:name="Language" android:theme="@android:style/Theme.NoTitleBar>

是它的外观的权利,但同时保持NoTitleBar属性,我想添加这个属性,以及:

Is how it looks right now, but while keeping the NoTitleBar attribute, I would like to add this attribute as well:

android:style/Theme.Light"

不过,我只是太新到Android,我不能弄明白。

But I'm just so new to Android that I can't figure it out.

请帮忙!

推荐答案

您不能马上在你的清单不止一个主题应用。

You cannot have more than one theme applied at once in your manifest.

我相信这是一个主题 Theme.Light.NoTitleBar ,会做你想要的 - 但我会告诉你下面你如何轻松地做自己,并自定义更多

I believe there is a theme Theme.Light.NoTitleBar that will do what you want - but I will show you below how you can easily do this yourself and customize more.

您需要做的是建立一个主题,有两种 Theme.NoTitleBar Theme.Light ,因为它是家长和定制你想要的位 - 在这种情况下,最简单的方法是创建 Theme.Light 主题,因为它的父,只是隐藏标题栏(而不是有在 Theme.NoTitleBar 作为家长,然后不得不作出一切轻这是更难!)。

What you need to do is create a theme which has either Theme.NoTitleBar or Theme.Light as it's parent and customizes the bits you want -- in this case the easiest way is to create a theme with Theme.Light as it's parent and just hide the title bar (rather than have the Theme.NoTitleBar as the parent and then have to make everything light which is much harder!).

您可以在的themes.xml 值文件文件夹,这样做有以下code

You can do this with the following code in your themes.xml file in the values folder:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <!-- use the Android Light theme as the base for our own theme -->
    <style name="MySuperTheme" parent="@android:style/Theme.Light">

        <!-- hide the Window Title -->
        <item name="android:windowNoTitle">true</item>

        <!-- You could change the scrollbar, checkbox style, anything! -->
    </style>

</resources>

然后使用安卓主题=@风格/ MySuperTheme为您的活动(或者你甚至可以通过将它的应用程序元素应用到你的整个应用程序 - - 如果你将样式应用于个人活动,对整个应用程序一组以及随后的单独活动的风格将显示)被一

Then use android:theme="@style/MySuperTheme" for your activity (or you could even apply it to your whole application by placing it on the application element -- if you apply a style to an individual activity and have one set for the whole application as well then the style of the individual activity will be the one shown).

看看Android的<一个href="https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml">themes.xml对于所有的事情,你可以在自己的主题自定义列表。

Take a look at the Android themes.xml for a list of all the things you can customize in your own theme.

您也可以看看所有的<一个href="https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/styles.xml">Android风格来看看他们是怎么做的。

You can also look at all of the Android styles to see how they are done.

这篇关于如何将多个主题的属性添加到Android清单相同的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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