Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message displayed on Toolbar #34

Open
Shahroz16 opened this issue Jan 14, 2015 · 5 comments · May be fixed by #39
Open

Message displayed on Toolbar #34

Shahroz16 opened this issue Jan 14, 2015 · 5 comments · May be fixed by #39

Comments

@Shahroz16
Copy link

Messages are being displayed on toolbar rather than under it like they do in case of Actionbar, any help ?

@kiratheone
Copy link

same with me :(

@matthew-reilly
Copy link
Contributor

If you are using new themes/toolbars, the positioning requires tweaking.

appMsg.setLayoutParams(getParams());

 /**
     * The new theme requires some layout tweaking for croutons
     */
    public FrameLayout.LayoutParams getParams() {
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        layoutParams.setMargins(0, getSupportActionBar().getHeight(), 0, 0);
        return layoutParams;
    }

@sgwhp sgwhp linked a pull request Oct 15, 2015 that will close this issue
@khirr
Copy link

khirr commented Mar 6, 2016

@matthew-reilly Your solution works but in Pre-Lollipop versions.
Is there a solution for 5.x y 6.x Android version?
Thanks.

@matthew-reilly
Copy link
Contributor

@khirr I would really recommend using Snackbar

@khirr
Copy link

khirr commented Mar 7, 2016

@matthew-reilly Thank you but it really necessary for me use it like "notifications" and not just to say a status change.

Finally I found a solution re-using yours:

private FrameLayout.LayoutParams getLayoutParams() {
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        int height = 0;
        if (mActivity.getSupportActionBar() != null) {
            height = mActivity.getSupportActionBar().getHeight();
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            height += getStatusBarHeight();
        }

        layoutParams.setMargins(0, height, 0, 0);
        return layoutParams;
    }

    private int getStatusBarHeight() {
        int result = 0;
        int resourceId = mActivity.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            result = mActivity.getResources().getDimensionPixelSize(resourceId);
        }
        return result;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants