当我尝试更改 SnackBar TextView 应用程序崩溃的颜色时

When I Try to Change the Color of SnackBar TextView App Crashes

logcat 中的错误:

10-20 13:51:31.926 12874-12874/com.project.android.tourism E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
10-20 13:51:32.110 12874-12874/com.project.android.tourism E/dalvikvm: Could not find class 'android.widget.ThemedSpinnerAdapter', referenced from method android.support.v7.widget.AppCompatSpinner$DropDownAdapter.<init>

和代码:

TextView textViewSnack = (TextView) findViewById(android.support.design.R.id.snackbar_text);   

textViewSnack.setTextColor(ContextCompat.getColor(PlaceActivity.this, R.color.colorPrimaryDark));

试试这个,

你需要通过view of SnackBar才能找到textView of SnackBar.

Snackbar snackbar = Snackbar.make(
                    coordinatorLayout,
                    "Snackbar: floatingActionButton1 (normal) clicked",
                    Snackbar.LENGTH_LONG);
snackbar.setActionTextColor(Color.RED); //to change the color of action text
View snackbarView = snackbar.getView();
snackbarView.setBackgroundColor(Color.WHITE);
TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextColor(ContextCompat.getColor(PlaceActivity.this, R.color.colorPrimaryDark));