[安卓开发基础] 国际化 style样式资源

本文探讨了如何根据系统语言设置自动切换UI界面语言,包括常见应用名词的中英文对照,并深入解析了Android中样式资源的使用,如子样式继承与父样式的规则及样式与主题的区别。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

根据系统 语言设置 自动切换成不同  语言。 

 

不同语言:

 

 

 

</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>

菜单资源文件:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值