SHARE
TWEET

Untitled

a guest Aug 24th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void showSnackBar (String myString, boolean longTime) {
  2.         int duration = longTime? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT;
  3.         Snackbar mySnackbar = Snackbar.make(thePhoto, myString, duration);
  4.         View myView = mySnackbar.getView();
  5.  
  6.         //use "android.support.design.R.id.snackbar_text" instead of "com.google.android.material" if you are not using Androidx
  7.         TextView myTextView = (TextView) myView.findViewById(com.google.android.material.R.id.snackbar_text);
  8.  
  9.         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
  10.             myTextView.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
  11.         else
  12.             myTextView.setGravity(Gravity.RIGHT);
  13.  
  14.         mySnackbar.show();
  15.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top