如何更改小吃店的背景颜色? [英] How to change background color of the snackbar?
本文介绍了如何更改小吃店的背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在AlertDialog的正面单击中的DialogFragment中显示小吃栏.这是我的代码段.
I am showing snackbar in DialogFragment Within the Positive click of alertDialog. Here is my code snippet.
Snackbar snackbar = Snackbar.make(view, "Please enter customer name", Snackbar.LENGTH_LONG)
.setAction("Action", null);
View sbView = snackbar.getView();
sbView.setBackgroundColor(Color.BLACK);
snackbar.show();
我正在将dialogfragment的视图传递给小吃店.我要背景色是黑色吗?我怎样才能做到这一点?我在DialogFragment中返回alertDialog.以及我要设置给对话框的主题,如下所示:
I am passing view of the dialogfragment to the snackbar. I want the background color black? How can I do this? I am returning alertDialog in the DialogFragment. And the theme I am setting to the dialog as follow's
<style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<!-- Used for the buttons -->
<item name="colorAccent">@color/accent</item>
<!-- Used for the title and text -->
<item name="android:textColorPrimary">@color/primary</item>
<!-- Used for the background -->
<item name="android:background">@color/white</item>
</style>
尽管我将对话框的背景色设置为白色,但应通过将小吃店的背景色设置为白色.
Although I am setting background color to white for dialog it should override by setting the background color to the snackbar.
推荐答案
尝试像这样设置背景颜色:
Try setting background color like this:
sbView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.BLACK));
它将100%工作!
这篇关于如何更改小吃店的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文