2016-07-04 56 views
0

以下文件定义我的应用程序使用的基本样式:如何找到Android“主题XML风格”的所有可能性?

<?xml version="1.0" encoding="utf-8"?> 
<resources> 

    <style name="Snapchat" parent="????" > 
    <item name="android:colorPrimaryDark">@color/Snapchat_violet</item> 
    <item name="android:colorPrimary">@color/Snapchat_blue</item> 
    <item name="android:colorAccent">@color/Snapchat_blue</item> 
    <item name="android:colorBackground">@color/Snapchat_white</item> 
    <item name="android:colorForeground">@color/Snapchat_yellow</item> 
    <item name="android:navigationBarColor">@color/Snapchat_grey</item> 
    </style> 
</resources> 

我想用一个标准的主题,父要继承,但我无法找到所有的标准主题的列表以及它们相应的XML名称/路径。

对不起,如果这是一个新手问题,但我不能在android文档中找到它。

+0

https://developer.android.com/guide/topics/ui/themes.html#PlatformStyles欢迎您! –

+0

好吧,我真的很笨,非常感谢你! –

回答

0

可以定义每个多种风格提交给我们ing标签,但每种款式都有其唯一标识款式的名称。的Android风格属性使用标签设置如下 -

<?xml version="1.0" encoding="utf-8"?> 
    <resources> 
    <style name="CustomFontStyle"> 
    <item name="android:layout_width">fill_parent</item> 
    <item name="android:layout_height">wrap_content</item> 
    <item name="android:capitalize">characters</item> 
    <item name="android:typeface">monospace</item> 
    <item name="android:textSize">12pt</item> 
    <item name="android:textColor">#00FF00</item>/> 

该值的可以是一个关键字字符串,十六进制颜色,到另一个资源类型的引用,或其它值取决于样式属性。 使用样式 一旦你的风格定义,你可以使用样式属性按如下方式使用它在你的XML布局文件 -

<TextView 
    android:id="@+id/text_id" 
    style="@style/CustomFontStyle" 
    android:text="@string/hello_world" /> 

    </LinearLayout> 

要实现自定义主题创建或编辑MyAndroidApp/RES /价值/主题。 XML并添加以下 -

<resources> 
... 
<style name="MyCustomTheme" parent="android:style/Theme"> 
<item name="android:textColorPrimary">#ffff0000. </item> 
</style> 
    ... 
</resources> 

在AndroidManifest.xml中应用主题的活动,你要的风格 -

<activity 
android:name="com.myapp.MyActivity" 
.... 
android:theme="@style/MyCustomTheme" 
/> 

您的新主题将应用于您的活动。

你也可以看看http://www.tutorialspoint.com/android/android_styles_and_themes.htm