1、layout的代码:
<TextViewandroid:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000"
android:textSize="70px"
android:text="@string/hello" />
2、strings.xml的代码:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">FirstProject</string>
<string name="hello">Hello world!</string>
<string name="action_settings">Settings</string>
</resources>
解释:@string/hello指的是在strings.xml文件中定义的hello字符串,即hello字符串中存有“Hello world!”,并在界面中输出。这种用法在将引用程序本地化为另一种语言时用到。
3、stings.xml
用来存储应用程序中所有 字符串常量。这使得您可以很容易地通过替换这些字符串并重新编译应用程序来本地化您的应用程序
本文介绍了Android应用开发中布局文件的编写方式与strings.xml资源文件的使用方法。具体包括TextView控件的基本属性设置,以及如何在布局文件中引用strings.xml中的字符串资源实现应用本地化。
1329

被折叠的 条评论
为什么被折叠?



