2016-02-29 63 views
0

一个内置的模板为Android Studio将创建下列主题:材料主题命名约定

<resources> 

    <!-- Base App Theme --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 

    <style name="AppTheme.NoActionBar"> 
     <item name="windowActionBar">false</item> 
     <item name="windowNoTitle">true</item> 
    </style> 

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

</resources> 

在这种情况下AppTheme.NoActionBar未明确指定AppTheme作为父。 Android是否使用命名约定并在此情况下隐式继承主题?

+0

看一看http://developer.android。 com/guide/topics/ui/themes.html#Inheritance –

+0

@DavidMedenjak随时发布我有什么作为答案,所以我可以接受你的答案。 – Dismissile

+0

谢谢,只要继续接受你的:) –

回答

0

感谢David指着我的文档:

如果你想从你自己定义的样式继承,你不必使用parent属性。 相反,只需将要继承的样式的名称作为新样式的名称前缀,并用句点分隔。例如,创建一个新的风格,继承了上述定义的CodeFont风格,但使红色,你可以创作新的风格是这样的:

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