niorgai / StatusBarCompat

Status Bar Utils ---- Change Status Bar Mode Simply

Home Page:http://niorgai.github.io/2016/03/20/Android-transulcent-status-bar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Toolbar goes underneath status bar

OneManStudioDotSe opened this issue · comments

I have a problem when using the translucent status bar inside a fragment.

What happens is that the toolbar (its title, icons and layout) goes underneath the status bar. The theme of the app is the following:

 <style name="OneManStudioTheme" parent="BaseTheme">
    </style>

    <!-- base app theme -->
    <style name="BaseTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
        <item name="colorPrimary">@color/blue_picton</item>
        <item name="colorPrimaryDark">@color/blue_cerulean</item>
        <item name="colorAccent">@color/pink_hot</item>
    </style>

I have also tried with

 <item name="windowActionBar">false</item>
 <item name="windowNoTitle">true</item>

inside the OneManStudioTheme but it has no effect :(

Any ideas what might be wrong?
Have you tested your library with the new Theme.MaterialComponents.Light.NoActionBar family of themes?

Any help would be greatly appreciated :)

commented

Which method do you call ?

If you call the method translucentStatusBar(), the contentView will underneath status bar , it works well because that is what the method mean to.

screenshot_20180927-115007

At the picture above I have the following:

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        StatusBarCompat.translucentStatusBar(getActivity(), false);

        customCarouselView = binding.carouselForStips;

        initializeTheView();
    }

As you can see, the toolbar is being drawn underneath the status bar which is not what I want.

What do you think might be wrong?

Is it possible to achieve the same result that the transluscentBar would give if I play around with the "fitSystemWindows" attribute of the the toolbar and the big image that I want to be drawn behind the status bar? Do you know how I can achieve it?

commented

That's what the method translucentStatusBar() mean to and it works well.

But i think you want the big image fullscreen and the toolbar show under the statusbar, the most easier way is add marginTop to toolbar, and the height can get from this method.

    public static int getStatusBarHeight(Context context) {
        int result = 0;
        int resId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resId > 0) {
            result = context.getResources().getDimensionPixelOffset(resId);
        }
        return result;
    }

I don't use fitSystemWindows because you cannot change it programmatically without restart Activity, in order to change it's height programmatically, i always change the marginTop.

If this can not help you, please show your layout file.

commented

I'm going to close this issue, if this issue is still present, please feel free to reopen it.