查找由android平台主题定义的所有可用样式

在几个android造型教程中,使用了父元素,我无法在android.R.style。*样式中find( http://developer.android.com/reference/android/R.style.html )。

一些示例来自http://android-developers.blogspot.com/2011/04/customizing-action-bar.html操作栏文章。 尼克使用父母的风格,如:

<style name="MyDropDownNav" parent="android:style/Widget.Holo.Light.Spinner.DropDown.ActionBar"> ... </style> 

要么

 <style name="MyActionBarTabStyle" parent="android:style/Widget.Holo.Light.ActionBarView_TabView"> ... </style> 

这些父母的风格从哪里来? 是否有可能列出所有可用的父母样式?

谢谢。

正如“应用样式和主题”文章所述:

Android平台提供了大量可在您的应用程序中使用的样式和主题。 您可以在R.style类中find所有可用样式的参考。 要使用此处列出的样式,请使用句号replace样式名称中的所有下划线。 例如,你可以使用"@android:style/Theme.NoTitleBar"来应用Theme_NoTitleBar主题。

然而, R.style参考文档没有很好的文档logging,并且没有详细描述样式,所以查看这些样式和主题的实际源代码将使您更好地了解每个样式属性。 要更好地参考Android风格和主题,请参阅以下源代码:

  • Android样式(styles.xml)
  • Android主题(themes.xml)

这些文件将帮助你通过例子来学习。 例如,在Android主题源代码中,您会find<style name="Theme.Dialog"> 。 在这个定义中,您将看到用于deviseAndroid框架使用的对话框的所有属性。

对于“android:style / Widget.Holo.Light.ActionBarView_TabView”,请参阅: http : //developer.android.com/reference/android/R.style.html#Widget_Holo_Light_ActionBar_TabView …并注意它的API级别!

对于“android:style / Widget.Holo.Light.Spinner.DropDown.ActionBar”试试: http : //developer.android.com/reference/android/R.style.html#Widget_Holo_Light_DropDownItem_Spinner

后者只是我最好的猜测 – 我不能让名单实际下降。

在创build自己的themesstyles时, Parent属性是可选的。 基本上, parent属性用于inheritance平台本身已经定义的样式。

如果我们希望inheritance一个themestyle并覆盖一些特征,我们可以使用parent属性。

这是所有可用平台定义styles的链接。

还有一个提示:

如果你想inheritance你自己创build的style ,就意味着按照这个例子来inheritance。

  <style name="MyDropDownNav.Red"> <item name="android:textColor">#FF0000</item> </style> 

以下是Official Google's Documentation ThemesStyles Google Android文档 Default List 文档

你可以在这里find这个文档

  • Android样式(styles.xml)
  • Android主题(themes.xml)

我知道上面的问题的答案在这里完成仍然让步的实施,因为这将有助于新手..

如何实现它们

这是我从themes.xml得到的

 <style name="Theme.NoTitleBar"> <item name="android:windowNoTitle">true</item> </style> 

现在在我的项目中to implement

我必须在我的Styles.xml文件中添加以下行

 <style name="AppTheme" parent="android:Theme.NoTitleBar" /> 

在这里,我创build了own theme名为“ AppThemeown theme ,它将inheritalready defined them by google属性。 所以我在parent提到它

通过查看themes.xmlstyles.xml不仅help to get the list of the already defined主题和样式help to get the list of the already defined还可以help novices to have an idea how to create主题。

作为主题,我在这里提到的parent是已经定义的android,所以我们将通过前缀android: to主题名称使用它。

如果你想inherit your created theme那么

 <style name="Theme2" parent="AppTheme"> <item name="android:windowNoTitle">true</item> <item name="android:windowFullscreen">true</item> <item name="android:windowContentOverlay">@null</item> </style> 

然后只提供style name to the parent ,在这里我使用Apptheme作为Apptheme父主题