├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── rebull │ │ └── adaptivestatusbar │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── rebull │ │ │ └── adaptivestatusbar │ │ │ ├── ActionBarActivity.java │ │ │ └── ToolBarActivity.java │ └── res │ │ ├── drawable │ │ └── author.png │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_main_actionbar.xml │ │ ├── content_layout.xml │ │ ├── content_layout_notoolbar.xml │ │ └── header_nav.xml │ │ ├── menu │ │ └── menu_nav.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_home_white_48dp.png │ │ ├── ic_launcher.png │ │ ├── ic_message_white_48dp.png │ │ ├── ic_settings_white_48dp.png │ │ └── login_out.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v19 │ │ └── dimens.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── rebull │ └── adaptivestatusbar │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | AdaptiveStatusBar -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.7 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # adaptiveStatusBar 2 | ###android系统状态栏--沉浸式/透明化--完整解决方案 3 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.rebull.adaptivestatusbar" 9 | minSdkVersion 15 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.1.1' 26 | compile 'de.hdodenhof:circleimageview:2.0.0' 27 | compile 'com.android.support:design:23.1.1' 28 | } 29 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\androidStudio\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/rebull/adaptivestatusbar/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.rebull.adaptivestatusbar; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/rebull/adaptivestatusbar/ActionBarActivity.java: -------------------------------------------------------------------------------- 1 | package com.rebull.adaptivestatusbar; 2 | 3 | import android.os.Build; 4 | import android.os.Bundle; 5 | import android.support.design.widget.NavigationView; 6 | import android.support.v4.widget.DrawerLayout; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.view.View; 9 | import android.view.WindowManager; 10 | import android.widget.Button; 11 | 12 | public class ActionBarActivity extends AppCompatActivity { 13 | 14 | private DrawerLayout mDrawerLayout; 15 | private NavigationView mNagigationView; 16 | private Button mBtn; 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_main_actionbar); 22 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 23 | WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes(); 24 | localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags); 25 | 26 | } 27 | initViews(); 28 | } 29 | 30 | private void initViews() { 31 | mDrawerLayout = (DrawerLayout) findViewById(R.id.id_drawerlayout); 32 | mNagigationView = (NavigationView) findViewById(R.id.id_navigationview); 33 | mNagigationView.inflateHeaderView(R.layout.header_nav); 34 | mNagigationView.inflateMenu(R.menu.menu_nav); 35 | mBtn = (Button) findViewById(R.id.goBack); 36 | mBtn.setOnClickListener(new View.OnClickListener() { 37 | @Override 38 | public void onClick(View v) { 39 | finish(); 40 | } 41 | }); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/rebull/adaptivestatusbar/ToolBarActivity.java: -------------------------------------------------------------------------------- 1 | package com.rebull.adaptivestatusbar; 2 | 3 | import android.content.Intent; 4 | import android.os.Build; 5 | import android.os.Bundle; 6 | import android.support.design.widget.NavigationView; 7 | import android.support.v4.widget.DrawerLayout; 8 | import android.support.v7.app.ActionBarDrawerToggle; 9 | import android.support.v7.app.AppCompatActivity; 10 | import android.support.v7.widget.Toolbar; 11 | import android.view.View; 12 | import android.view.WindowManager; 13 | import android.widget.Button; 14 | 15 | public class ToolBarActivity extends AppCompatActivity { 16 | 17 | private DrawerLayout mDrawerLayout; 18 | private NavigationView mNagigationView; 19 | private Toolbar mToolbar; 20 | private Button mBtn; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_main); 26 | 27 | initViews(); 28 | 29 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 30 | WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes(); 31 | localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags); 32 | if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){ 33 | //将侧边栏顶部延伸至status bar 34 | mDrawerLayout.setFitsSystemWindows(true); 35 | //将主页面顶部延伸至status bar;虽默认为false,但经测试,DrawerLayout需显示设置 36 | mDrawerLayout.setClipToPadding(false); 37 | } 38 | } 39 | 40 | } 41 | 42 | private void initViews() { 43 | mDrawerLayout = (DrawerLayout) findViewById(R.id.id_drawerlayout); 44 | mNagigationView = (NavigationView) findViewById(R.id.id_navigationview); 45 | mNagigationView.inflateHeaderView(R.layout.header_nav); 46 | mNagigationView.inflateMenu(R.menu.menu_nav); 47 | mToolbar = (Toolbar) findViewById(R.id.toolbar); 48 | mBtn = (Button) findViewById(R.id.goToActionBar); 49 | mToolbar.setTitle(""); 50 | if (mToolbar != null) { 51 | setSupportActionBar(mToolbar); 52 | } 53 | ActionBarDrawerToggle mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.open, R.string.close); 54 | mActionBarDrawerToggle.syncState(); 55 | mDrawerLayout.setDrawerListener(mActionBarDrawerToggle); 56 | mBtn.setOnClickListener(new View.OnClickListener() { 57 | @Override 58 | public void onClick(View v) { 59 | startActivity(new Intent(ToolBarActivity.this, ActionBarActivity.class)); 60 | } 61 | }); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/author.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljgsonx/adaptiveStatusBar/bcfc439091598024954dab506457cb6c2475c122/app/src/main/res/drawable/author.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main_actionbar.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | 23 | 24 | 25 | 26 | 27 | 32 | 37 |