Reputation: 1074
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?
Upvotes: 6
Views: 4233
Reputation: 3924
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"));
Upvotes: 21
Reputation: 3234
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.
Upvotes: 3