zoukankan      html  css  js  c++  java
  • [android] 安卓自定义样式和主题

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

    styles.xml

    <?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

    <?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

    <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="ss"
            android:theme="@style/MyTheme" >

  • 相关阅读:
    nginx配置二级目录,反向代理不同ip+端口
    一次实验环境中的数据库空间整理经历
    NFine中权限判断出错的问题
    Centos7 硬盘分区
    12个必备的JavaScript装逼技巧
    判断五大浏览器类型
    npm 常用命令及版本号浅析
    js 判断IE浏览器
    娱乐冷门小知识
    vue baidu Map 百度路书去掉动画
  • 原文地址:https://www.cnblogs.com/taoshihan/p/5689705.html
Copyright © 2011-2022 走看看