16
スナックバーの背景色を変更するには?
alertDialogのポジティブクリック内のDialogFragmentにスナックバーを表示しています。これが私のコードスニペットです。 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でalertDialogを返しています。そして、私がダイアログに設定しているテーマは次のとおりです <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> ダイアログの背景色を白に設定していますが、背景色をスナックバーに設定することで上書きする必要があります。