0

I fixed status bar color is white by this code

<style name="BaseTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="android:statusBarColor">@color/white</item>
    <item name="android:windowLightStatusBar" tools:targetApi="M">true</item>
</style>

So, status bar is white, and icon is black.

Image

In my project, I use library StfalconImageViewer for show images.

private fun showImageViewer(sourceImageView: ImageView?, position: Int) {
    val imageLoader = ImageLoader<String> { imageView, imageUrl ->
        loadImage(imageView, imageUrl)
    }
    StfalconImageViewer.Builder(context, imageUrls, imageLoader)
            .withHiddenStatusBar(false)
            .withStartPosition(position)
            .withTransitionFrom(sourceImageView)
            .show()
}

When dialog is showed, I seen status bar is back and icon is black too (because I fixed color with code above).

Image

How to make status bar icon color auto change, if status bar is black, icon color auto change to white. Or, another way of asking: I want to show StfalconImageViewer with status bar icon color is white.

Please give me some suggestion.

Thanks in advance.

PhongBM
  • 799
  • 10
  • 23
  • did you refer this example? https://medium.com/@imstudio/android-change-status-bar-text-color-659680fce49b – Modi Harsh Sep 12 '20 at 20:38
  • Thank @ModiHarsh, I have not tried configuring with java code yet, but I think it don't auto change between stats bar color and status bar icon color. – PhongBM Sep 13 '20 at 02:54
  • this is the answer https://stackoverflow.com/a/60163900/7138532 – Hamed Karami Nov 14 '20 at 17:04

1 Answers1

0

Status bar color as well as status bar icons color is independent of your background color. So you should change it by hands. As a solution I would advice to take area under status bar and using some library get most colors and according to it change status bar colors. And even in the case sometimes it could work incorrectly. So why not use half transparent dark background with light icons.

P.S. Do you really need to show status bar in the case? Maybe it's better to make full screen activity for the image viewer and show status bar only when some additional panels are shown.

alexanderktx
  • 148
  • 1
  • 4