通过字符串、颜色和尺寸资源改变文字及样式

来源:互联网 发布:手机版我的世界端口 编辑:程序博客网 时间:2024/05/26 19:19

1、res\values目录下的strings.xml

<resources>    <string name="app_name">Android8_1</string>    <string name="title">英雄联盟</string>    <string name="company">拳头公司</string>    <string name="url">游戏网址:www.lol.com</string>    <string name="introdce">《英雄联盟》(简称lol)是由美国Riot Games开发,腾讯游戏运营的英雄对战网游。《英雄联盟》除了即时战略、团队作战外,还拥有特色的英雄、自动匹配的战网平台,包括天赋树、召唤师系统、符文等元素。</string></resources>

2、res\values目录下的colors.xml

<?xml version="1.0" encoding="utf-8"?><resources>    <color name="title">#ff0</color>    <color name="company">#f70</color>    <color name="url">#9f60</color>    <color name="introduce">#7e8</color></resources>

3、res\values目录下的dimen.xml尺寸资源

<?xml version="1.0" encoding="utf-8"?><resources>    <dimen name="title">36px</dimen>    <dimen name="padding">6pt</dimen>    <dimen name="introduce">24px</dimen>    <dimen name="titlePadding">20px</dimen></resources>

4、布局文件

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:padding="@dimen/padding"    android:orientation="vertical" >    <TextView        android:text="@string/title"        android:padding="@dimen/titlePadding"        android:textSize="@dimen/title"        android:textColor="@color/title"        android:gravity="center"        android:layout_width="match_parent"        android:layout_height="wrap_content"    />    <TextView        android:textColor="@color/introduce"        android:text="@string/introduce"        android:textSize="@dimen/introduce"        android:layout_width="wrap_content"        android:layout_height="wrap_content"    />    <TextView        android:text="@string/company"        android:gravity="center"        android:textColor="@color/company"        android:padding="@dimen/padding"        android:layout_width="match_parent"        android:layout_height="wrap_content"    />    <TextView        android:text="@string/url"        android:gravity="center"        android:textColor="@color/url"        android:paddingLeft="@dimen/padding"        android:layout_width="match_parent"        android:layout_height="wrap_content"    /></LinearLayout>


0 0
原创粉丝点击