So, I started using the new Snackbar in the design support library, but I found that when you define “android: textColor” in your theme, this refers to the color of the text of the zakut. This is obviously a problem if your primary text color is dark.

Does anyone know a way around this or advise me how to color the text?
EDIT January 2017: (post-reply)
Although there are some specific solutions to fix the problem below, it is probably useful to provide the correct path to Snackbars themes.
First, you probably shouldn't define android:textColor in your themes at all (unless you know what the topic is). This sets the color of the text mainly for each view that connects to your theme. If you want to define text colors in your views that are not standard, use android:primaryTextColor and specify this attribute in your custom views.
However, to apply themes to Snackbar refer to this quality guide from a third-party material document: http://www.materialdoc.com/snackbar/ (Follow the implementation of the program theme so that it does not depend on the xml style)
For reference:
// create instance Snackbar snackbar = Snackbar.make(view, text, duration); // set action button color snackbar.setActionTextColor(getResources().getColor(R.color.indigo)); // get snackbar view View snackbarView = snackbar.getView(); // change snackbar text color int snackbarTextId = android.support.design.R.id.snackbar_text; TextView textView = (TextView)snackbarView.findViewById(snackbarTextId); textView.setTextColor(getResources().getColor(R.color.indigo)); // change snackbar background snackbarView.setBackgroundColor(Color.MAGENTA);
(You can also create your own Snackbar layouts, see the link above. Do it if this method is too hacked and you want a reliable way to update your custom Snackbar with possible support library updates).
And, alternatively, see the answers below for similar and possibly faster answers to solve your problem.
android android-support-library android-design-library snackbar
Mahonster Jun 25 '15 at 21:55 2015-06-25 21:55
source share