简体   繁体   English

为什么Snackbar不在屏幕上?

[英]Why snackbar is going out of the screen?

Basically I'm trying to show snackbar at the top .But the problem is it's upper half part is going out of the screen . 基本上我试图在顶部显示snackbar ,但是问题是它的上半部分不在屏幕上。 Can anyone please help me to resolve this issue? 谁能帮我解决这个问题?

Code: 码:

            Snackbar snackbar = Snackbar.make(search_btn, content, Snackbar.LENGTH_LONG);
        View sbView = snackbar.getView();
        sbView.setClickable(true);
        sbView.setFocusable(true);
        sbView.setBackgroundColor(Color.parseColor("#ffffff"));
        TextView tv = sbView.findViewById(android.support.design.R.id.snackbar_text);
        tv.setTextColor(Color.parseColor("#001919"));
        CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) sbView.getLayoutParams();
        params.gravity = Gravity.TOP;
        sbView.setLayoutParams(params);
        snackbar.show();

看起来一切都很好,也许您可​​以尝试向布局参数添加topMargin。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM