I want to display a text with an action on Design Support Library SnackBar.
My language is writen in Right-to-Left. So how can i change SnackBar text and action direction?
Something like this:
Finally from the answers and more searches i found this solution:
Snackbar snackbar =
Snackbar.make(view, "My right2left text", Snackbar.LENGTH_LONG)
.setAction("Action", new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
Set direction to Right-to-Left:
ViewCompat.setLayoutDirection(snackbar.getView(),ViewCompat.LAYOUT_DIRECTION_RTL);
Don't forget this for showing the snackbar:
snackbar.show();
UPDATE
Since you have Text
and Action
as TextView
you can use the other TextView methods for them. like as setTypeface()
, setTextSize()
and so on.
Set typeface for text:
TextView text = snackbar.getView().findViewById(android.support.design.R.id.snackbar_text);
text.setTypeface(yourTypeface);
Set typeface for action:
TextView action = snackbar.getView().findViewById(android.support.design.R.id.snackbar_action);
action.setTypeface(yourTypeface);