Skip to content

Commit

Permalink
修改
Browse files Browse the repository at this point in the history
  • Loading branch information
766770719 committed Dec 13, 2016
1 parent 92f1dc7 commit 915c63b
Show file tree
Hide file tree
Showing 14 changed files with 276 additions and 8 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions .idea/markdown-navigator.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/markdown-navigator/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 68 additions & 3 deletions README.md
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"
}
}
```
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ android {

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.github.766770719:StatusBar:1.0.0'
compile project(':statusbar')
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity android:name=".DemoActivity">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DemoActivity" />
<activity android:name=".DemoFragmentActivity" />

</application>

Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/zhx/statusbar/demo/DemoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@
import com.zhx.statusbar.StatusBarUtils;

/**
* Demo
* DemoActivity
* Created by owner on 2016/5/23.
*/
public class DemoActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo);
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自定义View
//解决:android:windowSoftInputMode=adjustResize,键盘弹出UI无法Resize问题 --> 布局XML中最后加入:KeyboardDisplayView(参考demo)
//注意:在使用KeyboardDisplayView的布局中,不能出现:android:fitsSystemWindows="true"
}
}
34 changes: 34 additions & 0 deletions app/src/main/java/com/zhx/statusbar/demo/DemoFragment.java
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 app/src/main/java/com/zhx/statusbar/demo/DemoFragmentActivity.java
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 app/src/main/java/com/zhx/statusbar/demo/MainActivity.java
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));
}
});
}
}
13 changes: 13 additions & 0 deletions app/src/main/res/layout/activity_demo_fragment.xml
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>
19 changes: 19 additions & 0 deletions app/src/main/res/layout/activity_main.xml
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.

0 comments on commit 915c63b

Please sign in to comment.