ActionBarSherlock mirrod属性 - 当使用"机器人:" preFIX? [英] ActionBarSherlock mirrod attributes -- when to use "android:" prefix?

查看:148
本文介绍了ActionBarSherlock mirrod属性 - 当使用"机器人:" preFIX?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在造型ActionBarSherlock我想知道,当我必须使用prefixed属性,当pfixed非$ P $属性,而当两者。例如:

 <项目名称=actionBarStyle> @风格/ Widget.Styled.ActionBar< /项目>
<项目名称=机器人:actionBarStyle> @风格/ Widget.Styled.ActionBar< /项目>
 

我发现在 ActionBarSherlock网站这样的解释:

  

镜像属性

     

由于Android的主题化系统限制任何自定义主题,必须在两个属性声明。正常android- prefixed属性应用主题本机操作栏和联合国prefixed属性自定义实现。由于这两个主题化的API正是你只需要引用您的自定义设置,而不是两次不必实现他们两次相同的。

     

最简单的方式来传达什么这需要是一个例子。以下是从病急乱投医的例子充分主题上面提到的:

 <样式名称=Theme.Styled父=Theme.Sherlock.Light.DarkActionBar>
    <项目名称=actionBarStyle> @风格/ Widget.Styled.ActionBar< /项目>
    <项目名称=机器人:actionBarStyle> @风格/ Widget.Styled.ActionBar< /项目>
< /风格>

<样式名称=Widget.Styled.ActionBar父=Widget.Sherlock.Light.ActionBar.Solid.Inverse>
    <项目名称=背景> @可绘制/ bg_striped< /项目>
    <项目名称=机器人:背景> @可绘制/ bg_striped< /项目>

    <项目名称=backgroundSplit> @可绘制/ bg_striped_split< /项目>
    <项目名称=机器人:backgroundSplit> @可绘制/ bg_striped_split< /项目>
< /风格>
 

我想,pfixed属性只都用于属性的非$ P $,即API级别11之前并不存在,但为什么会出现一个安卓背景在这个例子中,以及一个背景属性? 安卓背景的存在,因为API级别1。是否有人可以提供一些有关这些镜像属性的更多细节?

解决方案

据我所知,你引用ActionBarSherlock文档时,android- prefixed属性(你是唯一的一个,如果你使用的设置当ActionBarSherlock使用的ActionBar(即,在运行Android 3+,其中它的可用)设备,和非prefixed版本被用在较旧版本中,本机版本正常的ActionBar)时使用实际ActionBarSherlock有使用自己实现的ActionBar组件。

总之,android- prefixed属性均采用Android原生功能,以及非prefixed版本所使用的自定义组件。

总之,它看起来像你总是有主题化的ActionBarSherlock对象时同时设置prefixed和非prefixed属性。

When styling ActionBarSherlock I was wondering when I have to use the prefixed attribute, when the non-prefixed attribute, and when both. For example:

<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>

I found this explanation on the ActionBarSherlock website:

Mirrored Attributes

Due to limitations in Android's theming system any theme customizations must be declared in two attributes. The normal android-prefixed attributes apply the theme to the native action bar and the unprefixed attributes are for the custom implementation. Since both theming APIs are exactly the same you need only reference your customizations twice rather than having to implement them twice.

The easiest way to convey exactly what this entails is with an example. The following is the full theme from the "Styled" example mentioned above:

<style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
    <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
    <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
</style>

<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
    <item name="background">@drawable/bg_striped</item>
    <item name="android:background">@drawable/bg_striped</item>

    <item name="backgroundSplit">@drawable/bg_striped_split</item>
    <item name="android:backgroundSplit">@drawable/bg_striped_split</item>
</style>

I thought, non-prefixed attributes only have to be used for attributes, that did not exist before API level 11. But why is there an android:background as well as a background attribute in the example? android:background exists since API level 1. Can someone please give some more details about these mirrored attributes?

解决方案

From what I understand of the ActionBarSherlock documentation you quote, the android-prefixed attribute (which you would have been the only one to set if you used the "normal" ActionBar) is used when ActionBarSherlock uses the native version of ActionBar (that is, on devices running Android 3+, where it's available), and the non-prefixed version is used on older versions, when ActionBarSherlock actually has to use its own implementation of the ActionBar component.

In short, android-prefixed attributes are used by Android native features, and non-prefixed versions are used by custom components.

Anyway, it looks like you always have to set both prefixed and non-prefixed attribute when theming an ActionBarSherlock object.

这篇关于ActionBarSherlock mirrod属性 - 当使用&QUOT;机器人:&QUOT; preFIX?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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