Can I display material design Snackbar in dialog?

后端 未结 4 1792
隐瞒了意图╮
隐瞒了意图╮ 2021-01-17 12:24

I am developing an android application. In that I want to display material design Snackbar in dialog. Is it possible? If yes then how?

Please help me.

Thanks

4条回答
  •  无人及你
    2021-01-17 12:44

    If you're using a Dialog then:

    dialog_share = new Dialog(MainScreen.this, R.style.DialogTheme);
    dialog_share.requestWindowFeature(Window.FEATURE_NO_TITLE);
    LayoutInflater inflater = this.getLayoutInflater();
    mDialogView = inflater.inflate(R.layout.dialog_share, null);
    dialog_share.setContentView(mDialogView);
    dialog_share.getWindow().setBackgroundDrawableResource(R.color.translucent_black);
    dialog_share.show();
    
    public void ShowSnackBarNoInternetOverDialog() {
            Snackbar snackbar = Snackbar.make(mDialogView, getString(R.string.checkinternet), Snackbar.LENGTH_LONG);
            snackbar.setActionTextColor(Color.CYAN);
            snackbar.setAction("OK", new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    //Toast.makeText(MainScreen.this, "snackbar OK clicked", Toast.LENGTH_LONG).show();
                }
            });
            snackbar.show();
        }
    

提交回复
热议问题