Skip to content

Commit 1e6fbdb

Browse files
committed
fix toolbar color
1 parent 082f8b4 commit 1e6fbdb

File tree

7 files changed

+29
-7
lines changed

7 files changed

+29
-7
lines changed

app/src/main/java/com/werb/pickphotosample/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected void onCreate(Bundle savedInstanceState) {
4343
public void onClick(View view) {
4444
new PickPhotoView.Builder(MainActivity.this)
4545
.setPickPhotoSize(1)
46-
.setClickSelectable(true)
46+
.setClickSelectable(false)
4747
.setShowCamera(true)
4848
.setSpanCount(3)
4949
.setLightStatusBar(true)

pickphotoview/src/main/java/com/werb/pickphotoview/BasePickActivity.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.werb.pickphotoview
22

3+
import android.graphics.Color
34
import android.os.Build
45
import android.os.Bundle
56
import android.support.v7.app.AppCompatActivity
67
import android.view.View
7-
import com.werb.pickphotoview.extensions.color
88

99
/** Created by wanbo <[email protected]> on 2017/10/23. */
1010

@@ -18,11 +18,14 @@ open class BasePickActivity : AppCompatActivity() {
1818
private fun theme() {
1919
GlobalData.model?.let {
2020
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
21-
window.statusBarColor = color(it.statusBarColor)
21+
val decorView = window.decorView
22+
val option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
23+
decorView.systemUiVisibility = option
24+
window.statusBarColor = Color.TRANSPARENT
2225
}
2326
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
2427
if (it.lightStatusBar) {
25-
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
28+
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
2629
}
2730
}
2831
}

pickphotoview/src/main/java/com/werb/pickphotoview/PickPhotoActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class PickPhotoActivity : BasePickActivity() {
6363
private fun initToolbar() {
6464
val select = drawable(R.drawable.pick_svg_select)
6565
GlobalData.model?.let {
66-
appbar.setBackgroundColor(color(it.toolbarColor))
66+
toolbar.setBackgroundColor(color(it.toolbarColor))
67+
statusBar.setBackgroundColor(color(it.statusBarColor))
6768
midTitle.setTextColor(color(it.toolbarTextColor))
6869
cancel.setTextColor(color(it.toolbarTextColor))
6970
sure.setTextColor(alphaColor(color(it.toolbarTextColor)))

pickphotoview/src/main/java/com/werb/pickphotoview/PickPhotoPreviewActivity.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class PickPhotoPreviewActivity : BasePickActivity() {
5555

5656
private fun initToolbar() {
5757
GlobalData.model?.let {
58-
appbar.setBackgroundColor(color(it.toolbarColor))
58+
toolbar.setBackgroundColor(color(it.toolbarColor))
59+
statusBar.setBackgroundColor(color(it.statusBarColor))
5960
midTitle.setTextColor(color(it.toolbarTextColor))
6061
cancel.setTextColor(color(it.toolbarTextColor))
6162
if (selectImages.size > 0) {
@@ -117,6 +118,13 @@ class PickPhotoPreviewActivity : BasePickActivity() {
117118
window.decorView.systemUiVisibility = View.INVISIBLE
118119
} else {
119120
window.decorView.systemUiVisibility = View.VISIBLE
121+
GlobalData.model?.let {
122+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
123+
if (it.lightStatusBar) {
124+
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
125+
}
126+
}
127+
}
120128
}
121129
}
122130

pickphotoview/src/main/res/layout/pick_widget_my_toolbar.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
android:layout_width="match_parent"
66
android:layout_height="wrap_content">
77

8+
<View
9+
android:id="@+id/statusBar"
10+
android:layout_width="match_parent"
11+
android:layout_height="24dp" />
12+
813
<android.support.v7.widget.Toolbar
914
android:id="@+id/toolbar"
1015
android:layout_width="match_parent"

pickphotoview/src/main/res/layout/pick_widget_preview_toolbar.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
android:id="@+id/appbar"
5-
android:paddingTop="24dp"
65
android:layout_width="match_parent"
76
android:layout_height="wrap_content">
87

8+
<View
9+
android:id="@+id/statusBar"
10+
android:layout_width="match_parent"
11+
android:layout_height="24dp" />
12+
913
<android.support.v7.widget.Toolbar
1014
android:id="@+id/toolbar"
1115
android:layout_width="match_parent"

pickphotoview/src/main/res/values/styles.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources xmlns:tools="http://schemas.android.com/tools">
33
<style name="PickBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
4+
<item name="android:windowTranslucentStatus" tools:targetApi="kitkat">false</item>
45
</style>
56

67
<style name="Full.Theme" parent="Theme.AppCompat.Light.NoActionBar">

0 commit comments

Comments
 (0)