Skip to content

Commit 80f66e7

Browse files
committed
see 07/28 log
1 parent 1cd41d7 commit 80f66e7

File tree

9 files changed

+206
-183
lines changed

9 files changed

+206
-183
lines changed

app/src/main/java/com/blankj/androidutilcode/activity/StatusBarDrawerActivity.java

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ public class StatusBarDrawerActivity extends BaseDrawerActivity {
3434
private int mColor;
3535
private int mAlpha;
3636

37+
private View fakeStatusBar;
3738
private CheckBox cbAlpha;
3839
private TextView tvStatusAlpha;
3940
private SeekBar sbChangeAlpha;
4041
private Button btnRandomColor;
4142

4243
public static void start(Context context) {
43-
Intent starter = new Intent(context, StatusBarSwipeBackActivity.class);
44+
Intent starter = new Intent(context, StatusBarDrawerActivity.class);
4445
context.startActivity(starter);
4546
}
4647

@@ -53,11 +54,12 @@ public void initData(Bundle bundle) {
5354

5455
@Override
5556
public int bindLayout() {
56-
return R.layout.activity_status_bar_swipe_back;
57+
return R.layout.activity_status_bar_drawer;
5758
}
5859

5960
@Override
6061
public void initView(Bundle savedInstanceState, View view) {
62+
fakeStatusBar = findViewById(R.id.fake_status_bar);
6163
cbAlpha = (CheckBox) findViewById(R.id.cb_alpha);
6264
btnRandomColor = (Button) findViewById(R.id.btn_random_color);
6365
tvStatusAlpha = (TextView) findViewById(R.id.tv_status_alpha);
@@ -126,6 +128,32 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
126128
};
127129

128130
private void updateStatusBar() {
129-
BarUtils.setStatusBarColor(mActivity, mColor, mAlpha);
131+
// ViewGroup childAt = (ViewGroup) rootLayout.getChildAt(0);
132+
//
133+
// rootLayout.setFitsSystemWindows(false);
134+
// childAt.setFitsSystemWindows(false);
135+
// childAt.setClipToPadding(true);
136+
//
137+
// BarUtils.transparentStatusBar(this);
138+
// BarUtils.addStatusBarColor( childAt, mColor, mAlpha);
139+
140+
// BarUtils.transparentStatusBar(this);
141+
142+
143+
// rootLayout.setFitsSystemWindows(true);
144+
145+
146+
// BarUtils.addMarginTopEqualStatusBarHeight(cbAlpha);
147+
// BarUtils.addStatusBarColor((ViewGroup) rootLayout.getChildAt(0), mColor, mAlpha);
148+
149+
150+
if (!cbAlpha.isChecked()) {
151+
BarUtils.setFakeStatusBarColor(fakeStatusBar, mColor, mAlpha);
152+
BarUtils.setStatusBarAlpha(this, mAlpha);
153+
rootLayout.setFitsSystemWindows(false);
154+
} else {
155+
BarUtils.setStatusBarAlpha(this, mAlpha);
156+
}
157+
130158
}
131159
}

app/src/main/java/com/blankj/androidutilcode/activity/StatusBarSwipeBackActivity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
131131

132132
private void updateStatusBar() {
133133
if (!cbAlpha.isChecked()) {
134-
BarUtils.setStatusBarColor(StatusBarSwipeBackActivity.this, mColor, mAlpha);
134+
BarUtils.setStatusBarColor(this, mColor, mAlpha);
135+
135136
BarUtils.subtractMarginTopEqualStatusBarHeight(cbAlpha);
136137
} else {
137-
BarUtils.setStatusBarAlpha(StatusBarSwipeBackActivity.this, mAlpha);
138+
BarUtils.setStatusBarAlpha(this, mAlpha);
139+
138140
BarUtils.addMarginTopEqualStatusBarHeight(cbAlpha);
139141
}
140142
}

app/src/main/java/com/blankj/androidutilcode/base/BaseDrawerActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
4141

4242
@Override
4343
protected void setBaseView() {
44-
rootLayout = (DrawerLayout) findViewById(R.id.root_layout);
4544
contentView = LayoutInflater.from(this).inflate(R.layout.activity_drawer, null);
4645
setContentView(contentView);
46+
rootLayout = (DrawerLayout) findViewById(R.id.root_layout);
4747
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.activity_container);
4848
frameLayout.addView(LayoutInflater.from(this).inflate(bindLayout(), frameLayout, false));
4949
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
37 KB
Loading

app/src/main/res/layout/activity_drawer.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
android:layout_width="match_parent"
88
android:layout_height="match_parent"
99
android:background="@color/white"
10+
android:clipChildren="false"
11+
android:fitsSystemWindows="true"
1012
android:overScrollMode="never"
1113
tools:openDrawer="start">
1214

@@ -21,6 +23,7 @@
2123
android:layout_height="match_parent"
2224
android:layout_gravity="start"
2325
android:background="@color/white"
26+
android:fitsSystemWindows="false"
2427
app:headerLayout="@layout/nav_header"
2528
app:menu="@menu/activity_main_drawer" />
2629

app/src/main/res/layout/activity_status_bar_drawer.xml

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,57 @@
44
android:layout_width="match_parent"
55
android:layout_height="wrap_content"
66
android:gravity="center_horizontal"
7-
android:orientation="vertical"
8-
android:paddingLeft="@dimen/spacing_16"
9-
android:paddingRight="@dimen/spacing_16">
7+
android:orientation="vertical">
108

11-
<CheckBox
12-
android:id="@+id/cb_alpha"
13-
android:layout_width="wrap_content"
14-
android:layout_height="wrap_content"
15-
android:layout_gravity="center_horizontal"
16-
android:layout_margin="4dp"
17-
android:text="@string/status_bar_title_alpha" />
18-
19-
<TextView
20-
android:id="@+id/tv_status_alpha"
21-
style="@style/TextStyle"
22-
android:layout_width="wrap_content"
23-
android:layout_height="wrap_content"
24-
android:layout_gravity="center_horizontal" />
25-
26-
<SeekBar
27-
android:id="@+id/sb_change_alpha"
9+
<View
10+
android:id="@+id/fake_status_bar"
2811
android:layout_width="match_parent"
29-
android:layout_height="wrap_content"
30-
android:max="255"
31-
android:padding="@dimen/spacing_8"
32-
android:progress="112" />
12+
android:layout_height="0dp" />
3313

34-
<Button
35-
android:id="@+id/btn_random_color"
36-
style="@style/WideBtnStyle"
14+
<LinearLayout
3715
android:layout_width="match_parent"
3816
android:layout_height="wrap_content"
39-
android:text="@string/status_bar_random_color" />
17+
android:gravity="center_horizontal"
18+
android:orientation="vertical"
19+
android:paddingLeft="@dimen/spacing_16"
20+
android:paddingRight="@dimen/spacing_16">
4021

41-
<Button
42-
android:id="@+id/btn_set_transparent"
43-
style="@style/WideBtnStyle"
44-
android:layout_width="match_parent"
45-
android:layout_height="wrap_content"
46-
android:text="@string/status_bar_set_transparent" />
22+
<CheckBox
23+
android:id="@+id/cb_alpha"
24+
android:layout_width="wrap_content"
25+
android:layout_height="wrap_content"
26+
android:layout_gravity="center_horizontal"
27+
android:layout_margin="4dp"
28+
android:text="@string/status_bar_title_alpha" />
29+
30+
<TextView
31+
android:id="@+id/tv_status_alpha"
32+
style="@style/TextStyle"
33+
android:layout_width="wrap_content"
34+
android:layout_height="wrap_content"
35+
android:layout_gravity="center_horizontal" />
36+
37+
<SeekBar
38+
android:id="@+id/sb_change_alpha"
39+
android:layout_width="match_parent"
40+
android:layout_height="wrap_content"
41+
android:max="255"
42+
android:padding="@dimen/spacing_8"
43+
android:progress="112" />
44+
45+
<Button
46+
android:id="@+id/btn_random_color"
47+
style="@style/WideBtnStyle"
48+
android:layout_width="match_parent"
49+
android:layout_height="wrap_content"
50+
android:text="@string/status_bar_random_color" />
51+
52+
<Button
53+
android:id="@+id/btn_set_transparent"
54+
style="@style/WideBtnStyle"
55+
android:layout_width="match_parent"
56+
android:layout_height="wrap_content"
57+
android:text="@string/status_bar_set_transparent" />
4758

59+
</LinearLayout>
4860
</LinearLayout>

app/src/main/res/layout/activity_status_bar_swipe_back.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout
3+
android:id="@+id/ll_container"
34
xmlns:android="http://schemas.android.com/apk/res/android"
45
android:layout_width="match_parent"
56
android:layout_height="wrap_content"

app/src/main/res/layout/nav_header.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
<ImageView
99
android:layout_width="match_parent"
1010
android:layout_height="match_parent"
11+
android:background="@color/colorPrimary"
1112
android:scaleType="centerCrop"
12-
android:src="@drawable/bg_bar" />
13+
android:src="@mipmap/ic_launcher" />
1314

1415
<ImageView
1516
android:id="@+id/iv_avatar"
@@ -27,7 +28,7 @@
2728
android:layout_toRightOf="@id/iv_avatar"
2829
android:gravity="center_vertical"
2930
android:text="@string/author"
30-
android:textColor="@android:color/white"
31+
android:textColor="@color/black"
3132
android:textSize="@dimen/font_40"
3233
android:textStyle="bold" />
3334

@@ -40,6 +41,6 @@
4041
android:layout_marginLeft="@dimen/spacing_16"
4142
android:layout_marginTop="@dimen/spacing_8"
4243
android:text="@string/demo_of_android_util_code"
43-
android:textColor="@android:color/white"
44+
android:textColor="@color/black"
4445
android:textSize="@dimen/font_16" />
4546
</RelativeLayout>

0 commit comments

Comments
 (0)