机器人如何让AppCompat.Translucent类型题材的支持动作条?机器人、题材、动作、类型

2023-09-12 02:02:56 作者:褶皱

我想补充的支持动作条到我的活动之一我previously使用,但为了使我需要继承Theme.AppCompat动作条工作的支持,本次活动的theme.translucent已,我需要保持在这一活动的半透明的主题,但遗憾的是心不是一个Theme.AppCompat.translucent,我可以在默认情况下看到,有没有什么办法可以做到这一点?

I would like to add the support actionbar to one of my activities, I previously had been using the theme.translucent with this activity but in order to make the support actionbar work I needed to inherit the Theme.AppCompat, I need to maintain a translucent theme in this activity but unfortunately there isnt a Theme.AppCompat.translucent that i can see by default, is there any way that this can be done?

推荐答案

您可以创建一组新的样式要使用的具有相同的属性 Theme.Translucent themes.xml.

You can create a new set of styles to use which have the same properties as Theme.Translucent from themes.xml.

以下内容添加到您的styles.xml文件:

Add the following to your styles.xml file:

<style name="Theme.AppCompat.Translucent">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowAnimationStyle">@android:style/Animation</item>
</style>

您可以更改preFIX Theme.AppCompat 来的东西,如果你想从主题继承其他的东西,如对话框样式等。例如别人,一个名字像 Theme.AppCompat.Light.Translucent 将有光明的主题属性。

You can change the prefix Theme.AppCompat to something else if you want to inherit other things from the theme such as dialog styles etc. For example, a name like Theme.AppCompat.Light.Translucent would have the properties of the Light theme.

要使用新的样式,设置主题属性 @风格/ Theme.AppCompat.Translucent

To use the new style, set the theme property to @style/Theme.AppCompat.Translucent

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