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>

 

posted @ 2016-12-13 17:06  iFat  阅读(209)  评论(0编辑  收藏  举报