-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
276 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,70 @@ | ||
# StatusBar | ||
## 沉浸式状态栏、状态栏相关 | ||
沉浸式状态栏、状态栏相关 | ||
|
||
#### 1.maven { url "https://jitpack.io" } | ||
#### 2.compile 'com.github.766770719:StatusBar:1.0.0' | ||
<img width="400" height="720" src="https://github.com/766770719/Resources/blob/master/StatusBar/statusbar.png" /> | ||
|
||
###Gradle: | ||
[![](https://jitpack.io/v/766770719/StatusBar.svg)](https://jitpack.io/#766770719/StatusBar) | ||
|
||
###使用: | ||
#####1.在Activity中: | ||
``` | ||
public class DemoActivity extends Activity { | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.layout_demo); | ||
//隐藏MX的SmartBar | ||
SmartBarUtils.hide(getWindow().getDecorView()); | ||
//透明状态栏 | ||
StatusBarUtils.translucentStatusBar(this, findViewById(R.id.v_title)); | ||
//解决:android:windowSoftInputMode=adjustResize,键盘弹出UI无法Resize问题 --> 布局XML中最后加入:KeyboardDisplayView(参考demo) | ||
//注意:在使用KeyboardDisplayView的布局中,不能出现:android:fitsSystemWindows="true" | ||
} | ||
} | ||
``` | ||
|
||
#####2.在Fragment中: | ||
包含Fragment的Activity: | ||
``` | ||
public class DemoFragmentActivity extends FragmentActivity { | ||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_demo_fragment); | ||
//隐藏MX的SmartBar | ||
SmartBarUtils.hide(getWindow().getDecorView()); | ||
//透明状态栏,填充的控件在Fragment中,这里没有控件填null | ||
StatusBarUtils.translucentStatusBar(this, null); | ||
} | ||
} | ||
``` | ||
Fragment中: | ||
``` | ||
public class DemoFragment extends Fragment { | ||
@Nullable | ||
@Override | ||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
return inflater.inflate(R.layout.layout_demo, container, false); | ||
} | ||
@Override | ||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
//透明状态栏 | ||
StatusBarUtils.translucentStatusBar(this, view.findViewById(R.id.v_title)); | ||
//解决:android:windowSoftInputMode=adjustResize,键盘弹出UI无法Resize问题 --> 布局XML中最后加入:KeyboardDisplayView(参考demo) | ||
//注意:在使用KeyboardDisplayView的布局中,不能出现:android:fitsSystemWindows="true" | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/zhx/statusbar/demo/DemoFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.zhx.statusbar.demo; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v4.app.Fragment; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import com.zhx.statusbar.StatusBarUtils; | ||
|
||
/** | ||
* DemoFragment | ||
* Created by xiezihao on 16/12/13. | ||
*/ | ||
public class DemoFragment extends Fragment { | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
return inflater.inflate(R.layout.layout_demo, container, false); | ||
} | ||
|
||
@Override | ||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
|
||
//透明状态栏 | ||
StatusBarUtils.translucentStatusBar(this, view.findViewById(R.id.v_title)); | ||
|
||
//解决:android:windowSoftInputMode=adjustResize,键盘弹出UI无法Resize问题 --> 布局XML中最后加入:KeyboardDisplayView(参考demo) | ||
//注意:在使用KeyboardDisplayView的布局中,不能出现:android:fitsSystemWindows="true" | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/zhx/statusbar/demo/DemoFragmentActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.zhx.statusbar.demo; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v4.app.FragmentActivity; | ||
|
||
import com.zhx.statusbar.SmartBarUtils; | ||
import com.zhx.statusbar.StatusBarUtils; | ||
|
||
/** | ||
* Fragment中使用 | ||
* Created by xiezihao on 16/12/13. | ||
*/ | ||
public class DemoFragmentActivity extends FragmentActivity { | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_demo_fragment); | ||
|
||
//隐藏MX的SmartBar | ||
SmartBarUtils.hide(getWindow().getDecorView()); | ||
|
||
//透明状态栏,填充的控件在Fragment中,这里没有控件填null | ||
StatusBarUtils.translucentStatusBar(this, null); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/zhx/statusbar/demo/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.zhx.statusbar.demo; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
|
||
/** | ||
* 主页面 | ||
* Created by xiezihao on 16/12/13. | ||
*/ | ||
public class MainActivity extends Activity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
findViewById(R.id.v_activity).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
startActivity(new Intent(MainActivity.this, DemoActivity.class)); | ||
} | ||
}); | ||
|
||
findViewById(R.id.v_fragment).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
startActivity(new Intent(MainActivity.this, DemoFragmentActivity.class)); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<fragment | ||
android:id="@+id/f_demo" | ||
class="com.zhx.statusbar.demo.DemoFragment" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
android:padding="8dp"> | ||
|
||
<Button | ||
android:id="@+id/v_activity" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Activity中使用" /> | ||
|
||
<Button | ||
android:id="@+id/v_fragment" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Fragment中使用" /> | ||
</LinearLayout> |
File renamed without changes.