Before migrating to androidx, I used this code to change the typeface of snackbar text:
Snackbar snackbar = Snackbar.make(main_Coordinator, "No Connection", Snackbar.LENGTH_INDEFINITE);
View view = snackbar.getView();
TextView textView = view.findViewById(android.support.design.R.id.snackbar_text);
textView.setTypeface(Typeface.createFromAsset(getAssets(), "Shabnam.ttf"));
But after migrating to androidx I'm getting error for snackbar_text id android.support.design.R.id.snackbar_text
it says Cannot resolve symbol design
.
And also I am using the new design library com.google.android.material:material:1.0.0
Any help?
Just refer to the new design library like this -
Snackbar snackbar = Snackbar.make(main_Coordinator, "No Connection", Snackbar.LENGTH_INDEFINITE);
View view = snackbar.getView();
TextView textView = view.findViewById(com.google.android.material.R.id.snackbar_text);
textView.setTypeface(Typeface.createFromAsset(getAssets(), "Shabnam.ttf"));
Use com.google.android.material.R.id.snackbar_text
.
You've migrated to AndroidX, which means the library is different now. So the R
that you're referencing needs to come from the new library instead of the old one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With