zoukankan      html  css  js  c++  java
  • Android-主题

    主题分为两种:

      

       第一种:使用Android系统提供的主题

         第二种:自己定义主题

    样式 与 主题 区分理解

    样式是控制(View的子类风格)控件风格 或者 是(ViewGroup的子类风格)布局风格

    主题是控制整体风格(例如:Application  Activity 等)


    Android系统提供的主题:

    Activity使用Android系统提供的主题:


    Application 默认就使用来一个主题:android:theme="@style/AppTheme"

    <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">

    Activity 使用系统的主题:

         <!--
                对话框主题
                android:theme="@android:style/Theme.DeviceDefault.Dialog">
                android:theme="@android:style/Theme.Holo.Dialog"
                android:theme="@android:style/Theme.Dialog"
    
                android:theme="@style/Theme.AppCompat.Dialog"
                android:theme="@style/Theme.AppCompat.DayNight.Dialog"
                android:theme="@style/Base.Theme.AppCompat.Dialog.FixedSize"
                ...
    
                没有标题+全屏
                android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
    
                没有标题
                android:theme="@android:style/Theme.Black.NoTitleBar"
    
            -->
        <activity android:name=".ThemeActivity"
                android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
    
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
    
            </activity>

    使用Android系统主题的效果:


    自定义主题:

    自己去定义主题,首先要找到系统提供的主题文件

    android-16 android-22 android-xxx 平台版本无所谓,都可以的

    找到themes.xml文件打开阅读

    找到themes.xml文件打开阅读,要明白Android的这些窗体都是Window,所以直接找Window字样

    在values文件夹新建,themes.xml 主题文件:

    在themes.xml中定义主题,注意:自定义主题需要增加 android:才行,刚刚阅读系统主题是没有加android: 。

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <!-- 无标题主题 -->
        <style name="My_Theme_Not_Title">
            <item name="android:windowNoTitle">true</item>
        </style>
    
        <!-- 全屏主题(无状态栏 + 继承了parent="My_Theme_Not_Title" 无标题) -->
        <style name="My_Theme_Not_Title_Fullscreen" parent="My_Theme_Not_Title">
            <item name="android:windowFullscreen">true</item>
        </style>
    
    </resources>

    使用自定义主题:

    自定义主题:
                android:theme="@style/My_Theme_Not_Title_Fullscreen"
                android:theme="@style/My_Theme_Not_Title"
        <activity android:name=".ThemeActivity"
                android:theme="@style/My_Theme_Not_Title">
    
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
    
            </activity>

    自定义主题都效果:

  • 相关阅读:
    瀑布流事件
    js 面向对象 模拟日历
    leetcode 戳气球
    leetcode 地下城游戏
    laravel服务容器
    lru缓存策略
    php实现7种常见排序
    curl请求中http头的几种格式
    wireshark过滤规则(两年前记录在qq空间的日志)
    screen和nohub及&用法
  • 原文地址:https://www.cnblogs.com/android-deli/p/10100528.html
Copyright © 2011-2022 走看看