Created
August 12, 2019 16:15
-
-
Save asajadi84/6e4191b31a00e7b94b0a8985353a5876 to your computer and use it in GitHub Desktop.
Android RTL friendly Snackbar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void showSnackBar (String myString, boolean longTime) { | |
int duration = longTime? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT; | |
Snackbar mySnackbar = Snackbar.make(thePhoto, myString, duration); | |
View myView = mySnackbar.getView(); | |
//use "android.support.design.R.id.snackbar_text" instead of "com.google.android.material" if you are not using Androidx | |
TextView myTextView = (TextView) myView.findViewById(com.google.android.material.R.id.snackbar_text); | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) | |
myTextView.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); | |
else | |
myTextView.setGravity(Gravity.RIGHT); | |
mySnackbar.show(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment