zoukankan      html  css  js  c++  java
  • activity去标题栏操作&保留高版本主题

    方式一:每个类都需要去添加此代码
    在setContentView(R.layout.activity_splash);
    前设置以下代码
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    方式二:统一去掉所有activity的头

    @android:style/Theme.Light.NoTitleBar方式去头,使用老版本主题样式
    修改默认样式文件为
    <style name="AppTheme" parent="AppBaseTheme">
    <!-- 在去头的同时,还保留高版本的样式主题 -->
    <item name="android:windowNoTitle">true</item>
    </style>

    activity去标题栏操作

     protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            //去除掉当前activity头title
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.activity_splash);
    
        }

    保留高版本主题

    AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.itheima.mobilesafe74"
        android:versionCode="1"
        android:versionName="1.0" >
        <!-- android:versionCode 本地应用版本号1,版本号是2,有必要提示用户更新 -->
        <!-- android:versionName="1.0"  
                2.1.1:
                最后的一位:代表修复原有版本的bug
                倒数第二位:更新部分功能
                第一位:项目重大更新(代码重构,大部分功能添加,界面整体修改)-->
                
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="17" />
        <!-- android:theme="@android:style/Theme.Light.NoTitleBar"  -->
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
        
        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.itheima.mobilesafe74.activity.SplashActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity
                android:name="com.itheima.mobilesafe74.activity.HomeActivity"/>
        </application>
    
    </manifest>

    /res/values/styles.xml

       <!-- Application theme. -->
        <style name="AppTheme" parent="AppBaseTheme">
            <!-- 在去头的同时,还保留高版本的样式主题 -->
            <!-- All customizations that are NOT specific to a particular API-level can go here. -->
            <item name="android:windowNoTitle">true</item>
        </style>
  • 相关阅读:
    Python class:定义类
    Python return函数返回值详解
    Python None(空值)及用法
    Python函数值传递和引用传递(包括形式参数和实际参数的区别)
    Python函数的定义
    Python函数(函数定义、函数调用)用法详解
    Python reversed函数及用法
    Python zip函数及用法
    Python break用法详解
    Python嵌套循环实现冒泡排序
  • 原文地址:https://www.cnblogs.com/xufengyuan/p/6170688.html
Copyright © 2011-2022 走看看