2016-07-04 51 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