zoukankan      html  css  js  c++  java
  • 004、主题Theme的实现

    Theme可以用来整合Style制定
    Theme设置文件安排于Style.xml预加载的主题样式
    Style.xml文件中预设置的主题范例:
    <resources xmlns:android="http://schemas.android.com/apk/res/android">
     
        <!-- 基础应用程序主题,为默认主题 -->
        <style name="Theme" parent="android:Theme"></style>
     
        <!-- 更改应用程序的主题,使之具有translucent后台 -->
        <style name="Theme.Translucent">
            <item name="android:windowBackground">@drawable/translucent_background</item>
            <item name="android:windowNoTitle">false</item>
            <item name="android:colorForeground">@drawable/blue</item>
            <item name="android:colorBackground">@drawable/white</item>
        </style>
     
        <!-- 更改应用程序的主题,使之具有不同颜色后台且具有translucent后台 -->
        <style name="Theme.Translucent2">
            <item name="android:windowBackground">@drawable/pink</item>
            <item name="android:windowNoTitle">false</item>
            <item name="android:colorForeground">@drawable/darkgreen</item>
            <item name="android:colorBackground">@drawable/pink</item>
        </style>
     
        <!-- 更改应用程序的主题,使之具有透明transparent后台 -->
        <style name="Theme.Transparent">
            <item name="android:windowBackground">@drawable/transparent_background</item>
            <item name="android:windowNoTitle">false</item>
            <item name="android:colorForeground">@drawable/blue</item>
            <item name="android:colorBackground">@drawable/pink</item>
        </style>
        
        <style name="TextAppearance.Theme.PlainText" parent="android:TextAppearance.Theme">
            <item name="android:textStyle">normal</item>
        </style>
    </resources> 
     
    可以在Activity中通过setTheme方法来设置自定义的主题
         @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setTheme(R.style.Theme_Translucent);
            setContentView(R.layout.activity_theme);
        }

    也可以在AndroidManifest.xml文件中直接定义主题 

            <activity
                android:name="com.example.ex_3_21_theme.ThemeActivity"
                android:label="@string/app_name"
                android:theme="@style/Theme.Translucent2"
                 >
     
  • 相关阅读:
    CentOS7.4安装和配置Zabbix4.0
    CentOS7.4安装jdk1.8.0_201、Tomcat-8.5.38环境
    基于腾讯云CentOS7.4+MySQL5.7+Python3+uWSGI+Nginx的Django项目部署
    Windows Server 2008 R2环境下Apache2.4+Tomcat8配置
    Django2.1.5使用xadmin打造适合国人的后台管理系统
    Django2.1.3 smtp 邮件 553报警
    GitHub的Windows客户端的使用教程
    Ubuntu18.04的网络配置(静态IP和动态IP)
    CentOS6.X、7.X下Jenkins的安装及使用
    CentOS7下搭建Nginx+PHP7的安装配置
  • 原文地址:https://www.cnblogs.com/zyh-blog/p/3324480.html
Copyright © 2011-2022 走看看