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

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>


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值