├── .gitignore ├── README.md ├── build.gradle ├── demo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── jude │ │ └── demo │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── jude │ │ │ └── demo │ │ │ ├── FrameLayoutActivity.java │ │ │ ├── LinearLayoutActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── RelativeLayoutActivity.java │ │ │ ├── TestActivity.java │ │ │ └── TestView.java │ └── res │ │ ├── drawable-v21 │ │ ├── ic_menu_camera.xml │ │ ├── ic_menu_gallery.xml │ │ ├── ic_menu_manage.xml │ │ ├── ic_menu_send.xml │ │ ├── ic_menu_share.xml │ │ └── ic_menu_slideshow.xml │ │ ├── drawable │ │ ├── img0.png │ │ ├── img1.png │ │ ├── img2.png │ │ ├── img3.png │ │ └── side_nav_bar.xml │ │ ├── layout │ │ ├── activity_frame.xml │ │ ├── activity_linear.xml │ │ ├── activity_main.xml │ │ ├── activity_relative.xml │ │ ├── activity_test.xml │ │ └── nav_header_main.xml │ │ ├── menu │ │ ├── activity_main_drawer.xml │ │ └── main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v19 │ │ └── styles.xml │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── drawables.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── jude │ └── demo │ └── ExampleUnitTest.java ├── fitsystemwindowlayout ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── jude │ │ └── fitsystemwindowlayout │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── jude │ │ │ └── fitsystemwindowlayout │ │ │ ├── FitSystemWindowsFrameLayout.java │ │ │ ├── FitSystemWindowsLinearLayout.java │ │ │ ├── FitSystemWindowsRelativeLayout.java │ │ │ └── Utils.java │ └── res │ │ └── values │ │ └── attr.xml │ └── test │ └── java │ └── com │ └── jude │ └── fitsystemwindowlayout │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshot ├── screenshot1.jpg └── screenshot2.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .gradle 3 | .DS_Store 4 | /captures 5 | 6 | # built application files 7 | *.apk 8 | 9 | # files for the dex VM 10 | *.dex 11 | 12 | # Java class files 13 | *.class 14 | 15 | # generated files 16 | bin/ 17 | gen/ 18 | build 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Eclipse project files 24 | .classpath 25 | .project 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ 29 | 30 | # Intellij project files 31 | *.iml 32 | *.ipr 33 | *.iws 34 | .idea 35 | 36 | signing.properties -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## FitSystemWindowLayout 2 | 自动适应StatusBar与NavigationBar的Layout。 3 | 原理:根据你的配置自动设置基于StatusBar与NavigationBar的padding。 4 | 方便的建立类似这样的APP 5 | ![screenshot](screenshot/screenshot1.jpg) 6 | 7 | 自动处理4.4以下,4.4,5.0以上及有无虚拟按键以及横屏竖屏的各种复合情况下的`FrameLayout`,`LinearLayout`,`RelativeLayout`3种布局(好累...) 8 | ## 依赖 9 | `compile 'com.jude:fitsystemwindowlayout:2.1.5'` 10 | ## XML配置 11 | 在value中的styles.xml中设置 12 | 13 | 14 | 17 | 18 | 19 | 在value-v19中的styles.xml中设置 20 | 21 | 25 | 26 | 在value-v21中的styles.xml中设置 27 | 28 | 33 | 34 | 然后使用AppTheme这个主题,这是1个示例,应该看得出来吧。只要在你的AppTheme的v19版本和v21版本添加了相应属性就好。 35 | 36 | ## 使用 37 | 在根节点使用 38 | `FitSystemWindowsFrameLayout` 39 | `FitSystemWindowsLinearLayout` 40 | `FitSystemWindowsRelativeLayout` 41 | 就像: 42 | 43 | 49 | 50 | 51 | 54 | 55 | 56 | 57 | 58 | ## 3个基本属性 59 | 3种Layout都有这3个基本属性。 60 | 61 | app:padding_status="false"//默认为true 62 | app:padding_navigation="true"//默认为false 63 | app:status_color="#567890"//默认为colorPrimary, 64 | 65 | `padding_status`会自动增加StatusBar的位置的Padding,颜色默认是主题里的`ColorPrimary`; 66 | `padding_navigation`会自动增加NavigationBar位置的Padding。 67 | 68 | 默认效果是不能使用StatusBar的位置,可以使用NavigationBar的位置。 69 | 70 | ## 对子View的单独属性配置 71 | 对每个自己直接子View指定属性:(LinearLayout无效,都明白..) 72 | 73 | app:margin_status="false" 74 | app:margin_navigation="true" 75 | 这2个属性优先级比基本属性高。可以对每个View指定与StatusBar和NavigationBar的关系。 76 | 例: 77 | 78 | 86 | 87 | 96 | 97 | 105 | 106 | 107 | 108 | 109 | ## 可滑动View的内Padding处理 110 | 如果可滑动View的最后一个View这样显示。 111 | ![screenshot](screenshot/screenshot2.png) 112 | 那就没办法点击了。需要给它加一个内Padding。 113 | 所以可以给可滑动View添加这个属性(给需要的子View加) 114 | `app:padding_navigation="true"` 115 | 就像这样: 116 | 117 | 122 | 或者适用`com.jude.fitsystemwindowlayout.Utils.paddingToNavigationBar(view)` 123 | 这个属性只适用于可滑动View(ListView,RecyclerView,ScrollView等)。其他View无效。 124 | 125 | **详见demo** 126 | License 127 | ------- 128 | 129 | Copyright 2016 Jude 130 | 131 | Licensed under the Apache License, Version 2.0 (the "License"); 132 | you may not use this file except in compliance with the License. 133 | You may obtain a copy of the License at 134 | 135 | http://www.apache.org/licenses/LICENSE-2.0 136 | 137 | Unless required by applicable law or agreed to in writing, software 138 | distributed under the License is distributed on an "AS IS" BASIS, 139 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 140 | See the License for the specific language governing permissions and 141 | limitations under the License. 142 | 143 | 144 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.1.0' 9 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' 10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | mavenCentral() 19 | jcenter() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /demo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.jude.demo" 9 | minSdkVersion 14 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(include: ['*.jar'], dir: 'libs') 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.3.0' 26 | compile 'com.android.support:design:23.3.0' 27 | compile 'com.jude:rollviewpager:1.3.0' 28 | compile project(':fitsystemwindowlayout') 29 | } 30 | -------------------------------------------------------------------------------- /demo/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 F:\software\android-sdk_r24.0.2-windows\android-sdk-windows/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 | -------------------------------------------------------------------------------- /demo/src/androidTest/java/com/jude/demo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.jude.demo; 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 | } -------------------------------------------------------------------------------- /demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 17 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /demo/src/main/java/com/jude/demo/FrameLayoutActivity.java: -------------------------------------------------------------------------------- 1 | package com.jude.demo; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.NavigationView; 5 | import android.support.v4.view.GravityCompat; 6 | import android.support.v4.widget.DrawerLayout; 7 | import android.support.v7.app.ActionBarDrawerToggle; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.support.v7.widget.Toolbar; 10 | import android.view.Menu; 11 | import android.view.MenuItem; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | import android.widget.ImageView; 15 | 16 | import com.jude.fitsystemwindowlayout.Utils; 17 | import com.jude.rollviewpager.RollPagerView; 18 | import com.jude.rollviewpager.adapter.LoopPagerAdapter; 19 | 20 | public class FrameLayoutActivity extends AppCompatActivity 21 | implements NavigationView.OnNavigationItemSelectedListener { 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_frame); 27 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 28 | setSupportActionBar(toolbar); 29 | 30 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 31 | ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( 32 | this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 33 | drawer.setDrawerListener(toggle); 34 | toggle.syncState(); 35 | 36 | NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 37 | navigationView.setNavigationItemSelectedListener(this); 38 | 39 | RollPagerView pagerView = (RollPagerView) findViewById(R.id.viewpager); 40 | pagerView.setAdapter(new TestLoopAdapter(pagerView)); 41 | 42 | Utils.paddingToNavigationBar(findViewById(R.id.content)); 43 | } 44 | 45 | private class TestLoopAdapter extends LoopPagerAdapter { 46 | private int[] imgs = { 47 | R.drawable.img0, 48 | R.drawable.img1, 49 | R.drawable.img2, 50 | R.drawable.img3, 51 | }; 52 | 53 | public TestLoopAdapter(RollPagerView viewPager) { 54 | super(viewPager); 55 | } 56 | 57 | @Override 58 | public View getView(ViewGroup container, int position) { 59 | ImageView view = new ImageView(container.getContext()); 60 | view.setImageResource(imgs[position]); 61 | view.setScaleType(ImageView.ScaleType.CENTER_CROP); 62 | view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); 63 | return view; 64 | } 65 | 66 | @Override 67 | public int getRealCount() { 68 | return imgs.length; 69 | } 70 | 71 | } 72 | 73 | @Override 74 | public void onBackPressed() { 75 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 76 | if (drawer.isDrawerOpen(GravityCompat.START)) { 77 | drawer.closeDrawer(GravityCompat.START); 78 | } else { 79 | super.onBackPressed(); 80 | } 81 | } 82 | 83 | @Override 84 | public boolean onCreateOptionsMenu(Menu menu) { 85 | // Inflate the menu; this adds items to the action bar if it is present. 86 | getMenuInflater().inflate(R.menu.main, menu); 87 | return true; 88 | } 89 | 90 | @Override 91 | public boolean onOptionsItemSelected(MenuItem item) { 92 | // Handle action bar item clicks here. The action bar will 93 | // automatically handle clicks on the Home/Up button, so long 94 | // as you specify a parent activity in AndroidManifest.xml. 95 | int id = item.getItemId(); 96 | 97 | //noinspection SimplifiableIfStatement 98 | if (id == R.id.action_settings) { 99 | return true; 100 | } 101 | 102 | return super.onOptionsItemSelected(item); 103 | } 104 | 105 | @SuppressWarnings("StatementWithEmptyBody") 106 | @Override 107 | public boolean onNavigationItemSelected(MenuItem item) { 108 | // Handle navigation view item clicks here. 109 | int id = item.getItemId(); 110 | 111 | if (id == R.id.nav_camera) { 112 | // Handle the camera action 113 | } else if (id == R.id.nav_gallery) { 114 | 115 | } else if (id == R.id.nav_slideshow) { 116 | 117 | } else if (id == R.id.nav_manage) { 118 | 119 | } else if (id == R.id.nav_share) { 120 | 121 | } else if (id == R.id.nav_send) { 122 | 123 | } 124 | 125 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 126 | drawer.closeDrawer(GravityCompat.START); 127 | return true; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /demo/src/main/java/com/jude/demo/LinearLayoutActivity.java: -------------------------------------------------------------------------------- 1 | package com.jude.demo; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | import android.support.v7.widget.Toolbar; 6 | 7 | public class LinearLayoutActivity extends AppCompatActivity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_linear); 13 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 14 | setSupportActionBar(toolbar); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demo/src/main/java/com/jude/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.jude.demo; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.support.v7.widget.Toolbar; 7 | import android.view.View; 8 | 9 | public class MainActivity extends AppCompatActivity { 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_main); 15 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 16 | setSupportActionBar(toolbar); 17 | findViewById(R.id.frame).setOnClickListener(new View.OnClickListener() { 18 | @Override 19 | public void onClick(View v) { 20 | startActivity(new Intent(MainActivity.this,FrameLayoutActivity.class)); 21 | } 22 | }); 23 | findViewById(R.id.linear).setOnClickListener(new View.OnClickListener() { 24 | @Override 25 | public void onClick(View v) { 26 | startActivity(new Intent(MainActivity.this,LinearLayoutActivity.class)); 27 | } 28 | }); 29 | findViewById(R.id.relative).setOnClickListener(new View.OnClickListener() { 30 | @Override 31 | public void onClick(View v) { 32 | startActivity(new Intent(MainActivity.this,RelativeLayoutActivity.class)); 33 | } 34 | }); 35 | findViewById(R.id.test).setOnClickListener(new View.OnClickListener() { 36 | @Override 37 | public void onClick(View v) { 38 | startActivity(new Intent(MainActivity.this,TestActivity.class)); 39 | } 40 | }); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /demo/src/main/java/com/jude/demo/RelativeLayoutActivity.java: -------------------------------------------------------------------------------- 1 | package com.jude.demo; 2 | 3 | import android.support.design.widget.NavigationView; 4 | import android.support.v4.view.GravityCompat; 5 | import android.support.v4.widget.DrawerLayout; 6 | import android.support.v7.app.ActionBarDrawerToggle; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.os.Bundle; 9 | import android.support.v7.widget.Toolbar; 10 | import android.view.Menu; 11 | import android.view.MenuItem; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | import android.widget.ImageView; 15 | 16 | import com.jude.fitsystemwindowlayout.Utils; 17 | import com.jude.rollviewpager.RollPagerView; 18 | import com.jude.rollviewpager.adapter.LoopPagerAdapter; 19 | 20 | public class RelativeLayoutActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_relative); 26 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 27 | setSupportActionBar(toolbar); 28 | 29 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 30 | ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( 31 | this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 32 | drawer.setDrawerListener(toggle); 33 | toggle.syncState(); 34 | 35 | NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 36 | navigationView.setNavigationItemSelectedListener(this); 37 | 38 | RollPagerView pagerView = (RollPagerView) findViewById(R.id.viewpager); 39 | pagerView.setAdapter(new TestLoopAdapter(pagerView)); 40 | 41 | Utils.paddingToNavigationBar(findViewById(R.id.content)); 42 | } 43 | 44 | private class TestLoopAdapter extends LoopPagerAdapter { 45 | private int[] imgs = { 46 | R.drawable.img0, 47 | R.drawable.img1, 48 | R.drawable.img2, 49 | R.drawable.img3, 50 | }; 51 | 52 | public TestLoopAdapter(RollPagerView viewPager) { 53 | super(viewPager); 54 | } 55 | 56 | @Override 57 | public View getView(ViewGroup container, int position) { 58 | ImageView view = new ImageView(container.getContext()); 59 | view.setImageResource(imgs[position]); 60 | view.setScaleType(ImageView.ScaleType.CENTER_CROP); 61 | view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); 62 | return view; 63 | } 64 | 65 | @Override 66 | public int getRealCount() { 67 | return imgs.length; 68 | } 69 | 70 | } 71 | 72 | @Override 73 | public void onBackPressed() { 74 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 75 | if (drawer.isDrawerOpen(GravityCompat.START)) { 76 | drawer.closeDrawer(GravityCompat.START); 77 | } else { 78 | super.onBackPressed(); 79 | } 80 | } 81 | 82 | @Override 83 | public boolean onCreateOptionsMenu(Menu menu) { 84 | // Inflate the menu; this adds items to the action bar if it is present. 85 | getMenuInflater().inflate(R.menu.main, menu); 86 | return true; 87 | } 88 | 89 | @Override 90 | public boolean onOptionsItemSelected(MenuItem item) { 91 | // Handle action bar item clicks here. The action bar will 92 | // automatically handle clicks on the Home/Up button, so long 93 | // as you specify a parent activity in AndroidManifest.xml. 94 | int id = item.getItemId(); 95 | 96 | //noinspection SimplifiableIfStatement 97 | if (id == R.id.action_settings) { 98 | return true; 99 | } 100 | 101 | return super.onOptionsItemSelected(item); 102 | } 103 | 104 | @SuppressWarnings("StatementWithEmptyBody") 105 | @Override 106 | public boolean onNavigationItemSelected(MenuItem item) { 107 | // Handle navigation view item clicks here. 108 | int id = item.getItemId(); 109 | 110 | if (id == R.id.nav_camera) { 111 | // Handle the camera action 112 | } else if (id == R.id.nav_gallery) { 113 | 114 | } else if (id == R.id.nav_slideshow) { 115 | 116 | } else if (id == R.id.nav_manage) { 117 | 118 | } else if (id == R.id.nav_share) { 119 | 120 | } else if (id == R.id.nav_send) { 121 | 122 | } 123 | 124 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 125 | drawer.closeDrawer(GravityCompat.START); 126 | return true; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /demo/src/main/java/com/jude/demo/TestActivity.java: -------------------------------------------------------------------------------- 1 | package com.jude.demo; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | 6 | public class TestActivity extends AppCompatActivity { 7 | 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | setContentView(R.layout.activity_test); 12 | } 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /demo/src/main/java/com/jude/demo/TestView.java: -------------------------------------------------------------------------------- 1 | package com.jude.demo; 2 | 3 | import android.content.Context; 4 | import android.graphics.Rect; 5 | import android.util.AttributeSet; 6 | import android.util.Log; 7 | import android.view.WindowInsets; 8 | import android.widget.FrameLayout; 9 | 10 | public class TestView extends FrameLayout { 11 | 12 | public TestView(Context context) { 13 | super(context); 14 | } 15 | 16 | public TestView(Context context, AttributeSet attrs) { 17 | super(context, attrs); 18 | } 19 | 20 | public TestView(Context context, AttributeSet attrs, int defStyleAttr) { 21 | super(context, attrs, defStyleAttr); 22 | } 23 | 24 | @Override 25 | public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) { 26 | Log.i(getTag()+" TestActivity","dispatchApplyWindowInsets "+insets); 27 | return super.dispatchApplyWindowInsets(insets); 28 | } 29 | 30 | @Override 31 | public WindowInsets onApplyWindowInsets(WindowInsets insets) { 32 | Log.i(getTag()+" TestActivity","onApplyWindowInsets "+insets); 33 | return super.onApplyWindowInsets(insets); 34 | } 35 | 36 | @Override 37 | protected boolean fitSystemWindows(Rect insets) { 38 | Log.i(getTag()+" TestActivity","fitSystemWindows " +insets); 39 | return super.fitSystemWindows(insets); 40 | } 41 | } -------------------------------------------------------------------------------- /demo/src/main/res/drawable-v21/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable-v21/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable-v21/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable-v21/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable-v21/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable-v21/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/img0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/FitSystemWindowLayout/9b0a141d81ee5f30c72518525835ea63fb2e16ee/demo/src/main/res/drawable/img0.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/FitSystemWindowLayout/9b0a141d81ee5f30c72518525835ea63fb2e16ee/demo/src/main/res/drawable/img1.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/img2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/FitSystemWindowLayout/9b0a141d81ee5f30c72518525835ea63fb2e16ee/demo/src/main/res/drawable/img2.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/img3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/FitSystemWindowLayout/9b0a141d81ee5f30c72518525835ea63fb2e16ee/demo/src/main/res/drawable/img3.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_frame.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 21 | 22 | 30 | 31 | 37 | 42 | 43 | 44 | 49 | 50 | 58 | 59 | 60 | 61 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_linear.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 20 | 21 | 25 | 31 | 37 | 43 | 49 | 55 | 61 | 67 | 73 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 18 | 19 |