1. 程式人生 > >[安卓開發基礎] 國際化 style樣式資源

[安卓開發基礎] 國際化 style樣式資源

根據系統 語言設定 自動切換成不同  語言。 

 

不同語言:

 

 

 

</string>

    <string
name="textView1">微信</string>
    <string
name="textView2">通訊錄</string>
    <string
name="textView3">QQ</string>
    <string

name="textView4">相機</string>
    <string
name="textView5">時鐘</string>
    <string
name="textView6">備忘錄</string>
    <string
name="textView7">音樂</string>
    <string
name="textView8">網際網路</string>
    <string
name="textView9">郵件</string>

 

<resources>
    <string
name="app_name">Windows Phone</string>
    <string
name="textView1">WeChat</string>
    <string
name="textView2">Contacts</string>
    <string

name="textView3">QQ</string>
    <string
name="textView4">Camera</string>
    <string
name="textView5">Clock</string>
    <string
name="textView6">Notes</string>
    <string
name="textView7">Music</string>
    <string
name="textView8">Browser</string>
    <string
name="textView9">E-mail</string>
</resources>

樣式資源:

 

 

子樣式繼承與父樣式, 子樣式屬性與父樣式相同時候以子樣式為準。

<LinearLayout
   
android:layout_width="match_parent"
   
android:layout_height="wrap_content"
   
android:orientation="vertical"
   
>
    <TextView
       
android:layout_width="match_parent"
       
android:layout_height="wrap_content"
       
style="@style/title"
       
android:text="style父樣式"
       
/>
    <TextView
       
android:layout_width="match_parent"
       
android:layout_height="wrap_content"
       
style="@style/context"
       
android:text="子樣式"
       
/>
</LinearLayout>

 

 

 

樣式style與主題theme的區別:

 

 

 

 

 

 

 

 

 

Bold 為黑色加粗

 

 

<!-- 加粗  -->
<style name="block">
    <item
name="android:textStyle">bold</item>
    <item
name="android:textColor">#000</item>
</style>
<style
name="text_block" parent="block">
    <item
name="android:textStyle">bold</item>
   <item
name="android:layout_gravity">center_horizontal</item>
</style>

選單資原始檔: