android布局values下文档使用

来源:互联网 发布:python函数执行shell 编辑:程序博客网 时间:2024/05/12 13:14

values下面一般会自动创建一个strings.xml文档如下:

<resources>

    <string name="hello">Hello World, ActivityMain!</string>

</resources>

此时我们就可以在xml中用xxx="@string/app_name"来引用该值。

而<resources>标签下除了<string>标签外还有其他一些标签,下面把我知道的一一细数:

1,<string>

<string name="hello">Hello World, ActivityMain!</string>

<TextView android:text="@string/hello" />

getResources().getString(R.string.hello);

2,<string-array>

<string-array name="grades">

<item>语文</item>

<item>数学</item>

<string-array>

getResources().getStringArray(R.array.grade);

3,<color> 

<color name="blue">#FF0000FF</color>

<color name="red">#FFFF0000</color>

<TextView android:textColor="@color/red" />

getResources().getColor(R.color.red);

4,<dimen>

<dimen name="fontsize1">30dip</dimen>

<dimen name="fontsize2">24sp</dimen>

<TextView android:textSize="@dimen/fontsize1" />

getResources().getDimension(R.dimen.fontsize1);

5,<style>

 <style name="pop_in_out">

  <item name="android:windowEnterAnimation">@anim/zoom_in</item>

  <item name="android:windowExitAnimation">@anim/zoom_out</item>

 </style>

原创粉丝点击