zoukankan      html  css  js  c++  java
  • Android学习笔记主题(Theme)资源文件

    安卓的主题资源文件,可以用于对Android应用的美化。

    styles文件是主题资源文件。
    定义一个主题资源格式如下:

    <resources>
        <!-- Base application theme. -->
        <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
            <!-- Customize your theme here. -->
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
        </style>
    
        <style name="bgTheme" parent="@style/AppTheme">
            <item name="android:windowNoTitle">false</item>
            <item name="android:windowBackground">@drawable/bg</item>
        </style>
    </resources>
    

    引用主题资源可以在AndroidManifest资源中通过 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引用

        <activity android:name=".MainActivity"
                android:theme="@style/bgTheme">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
         </activity>
    

    还可以通过Java代码引用

        setTheme(R.style.bgTheme);
        setContentView(R.layout.activity_main);
    

    注意:如果使用Java代码应用要写在 setContentView(R.layout.activity_main) 之前

  • 相关阅读:
    【转】苹果App Store审核指南中文翻译(更新)
    ios中的coredata的使用
    iOS开发——网络编程OC篇&Socket编程
    [深入浅出Cocoa]iOS网络编程之Socket
    RESTful架构详解
    IOS开发 REST请求 ASIHTTPRequest用法
    iOS 8 AutoLayout与Size Class自悟
    nodejs入门demo
    微信公众号查询账户余额等
    微信公众号token验证失败的一些总结
  • 原文地址:https://www.cnblogs.com/lzpq/p/12885237.html
Copyright © 2011-2022 走看看