Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
443 views
in Technique[技术] by (71.8m points)

android - appcompat-v7 v23.0.0 statusbar color black when in ActionMode

UPDATE

Same issue present in the latest Gmail app. I still don't understand why would Google make such unpleasant UI change. Obsessive in me goes crazy whenever I see it

QUESTION

I have this weird issue with appcompat-v7 23. Issue I am going to describe does not happen with 22 series

You can get source code that reproduces this issuse form https://github.com/devserv/t/ Once built, you can tap and hold an item in the list to activate ActionMode

Issue:

When in ActionMode, appcompat turns status bar to black. This does not happen if I don’t use following

<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>

in my v21 style but I have to use it because I want my navigation drawer to look behind status bar.


I used to use following to avoid black status bar when ActionMode started and ended

 public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.appColorPrimaryDark));
    }

}

 public void onDestroyActionMode(ActionMode actionMode) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getActivity().getWindow().setStatusBarColor(getResources().getColor(android.R.color.transparent));
     }

    mMode = null;
}

Above code did not create/avoided status bar turning black, but does not work properly on v23 of appcompat. Instead you see a short black status bar while ActionMode destroyed. It looks like related to the animation that plays when ActionMode destroyed.

I have tried to open bug reports but it has been declined with comment

Don't re-create bugs.

Am I missing something?

Here are the screenshots for normal and action mode.

enter image description here enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In case only the color is the issue, you can change it. Only to a fixed color resource.

<color name="abc_input_method_navigation_guard" tools:override="true">@color/primary_dark</color>

Obvious ?colorPrimaryDark will not work, not even on API 21.


The view responsible for the black status bar background is stored in AppCompatDelegateImplV7.mStatusGuard. You can get the delegate by calling getDelegate() from your activity and access mStatusGuard field by reflection. After starting the action mode you can get a reference to this view and customize it however you like.

This was found in AppCompat 24.1.1.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...