前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >[android] 安卓自定义样式和主题

[android] 安卓自定义样式和主题

作者头像
唯一Chat
发布2019-09-10 16:34:37
9080
发布2019-09-10 16:34:37
举报
文章被收录于专栏:陶士涵的菜地陶士涵的菜地

简单练习自定义样式和主题,样式是加在View上,主题是加在Application或者Activity上

styles.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 自定义样式 -->
    <style name="MyFont">
        <item name="android:textColor">#ff0000</item>
        <item name="android:textSize">40sp</item>
    </style>
    <style name="MyFontSon" parent="@style/MyFont">
        <item name="android:textSize">30sp</item>
    </style>
    <!-- 自定义主题 -->
    <style name="MyTheme">
        <item name='android:windowNoTitle'>true</item>
        <item name="android:background">#ffffff</item>
    </style>
</resources>

activity_main.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    
    <TextView
        style="@style/MyFont"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="样式和主题"
        />
    <TextView
        style="@style/MyFontSon"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="样式和主题"
        />
</LinearLayout>

Manifest.xml

代码语言:javascript
复制
<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="ss"
        android:theme="@style/MyTheme" >
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-07-20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档