如何做appcompat库的造型工作 [英] how does appcompat library styling work

查看:196
本文介绍了如何做appcompat库的造型工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑如何造型在appcompat库的工作原理。

I'm quite confused about how styling in appcompat library works.

根据这里

我们现在使用工具栏/动作条上所有支持实施   平台,这意味着我们不再阅读任何Android的:属性   有关行动吧。

We now use the support implementation of Toolbar/ActionBar on all platforms meaning that we no longer read any android: attributes related to the action bar.

对于那些已经拥有现有appcompat设置的应用程序,这意味着,   您应该删除它在重新设置的值相同的V14 +主题   Android的命名空间。请注意,这是仅适用于   款式/部件影响的行动吧。

For apps which already have existing appcompat setups, this means that you should remove your v14+ themes which re-set the same values in the android namespace. Please note, this is ONLY applicable for styles/widgets which affect the action bar.

对于大多数应用程序,你现在只需要一个主题的宣言,在值/

For most apps, you now only need one theme declaration, in values/

因此​​,这里是我的问题:

So here is my question:

如果我想使用材料设计动作条在API 14+,我可以只使用与机器人提供appcompat_v7和风格是在共同价值/文件夹动作条/工具栏命名空间中删除?但为什么我看到人们写低于code:

If I want to use material design ActionBar in API 14+, I can just use ActionBar/Toolbar provided in appcompat_v7 and style it in the common value/ folder with the "android:" namespace removed ? but why am I seeing people writing code below:

<style name="MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    ....
    <item name="windowContentOverlay">@null</item>
    <item name="android:windowContentOverlay">@null</item>
    ....
</style>

为什么是机器人的命名空间呢?什么是之间的code以上,用价值V21,价值-V14,文件夹?区别

why is "android:" namespace there? what's the difference between the code above and using value-v21, value-v14, folders?

可有人解释或指引我正确的来源?

can someone explain or direct me to the right source?

推荐答案

是的,如果你使用AppCompat V21 +,你只需要与一个父一个主题 Theme.AppCompat (或分专题,如 Theme.AppCompat.Light )和你的不可以需要机器人:命名空间属性的动作栏/窗口相关的标志,也没有独立的主题V14,V20等顶级属性的完整列表,其中AppCompat提供跨所有层次的API可以在的 AppCompat R.styleable主题

Yes, if you use AppCompat v21+, you only need a single theme with a parent of Theme.AppCompat (or a subtheme such as Theme.AppCompat.Light) and you do not need the android: namespace attributes for action bar/window related flags, nor separate themes for v14, v20, etc. The full list of top level attributes which AppCompat provides across all API levels can be found in the AppCompat R.styleable Theme.

大部分的code互联网(包括developer.android.com网站的部分)上仍然为pre-V21 AppCompat编写的,其中的没有的要求都机器人:和非prefixed版本

Much of the code on the internet (including parts of the developer.android.com site) are still written for the pre-v21 AppCompat, which did require both the android: and non-prefixed versions.

这篇关于如何做appcompat库的造型工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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