src/main/java/de/blau/android/util/Snack.java
/**
     * Display a toast underneath the top action bar
     * 
     * @param context Android Context that called this
     * @param msg the message to display
     * @param color background color of the message
     * @param duration how long to display the message
     */
Display a toast underneath the top action bar

@param context Android Context that called this
@param msg the message to display
@param color background color of the message
@param duration how long to display the message
Display a toast underneath the top action bar @param context Android Context that called this @param msg the message to display @param color background color of the message @param duration how long to display the message
private static void toastTop(@NonNull Context context, @NonNull String msg, int color, int duration) {
        try {
            LayoutInflater inflater = LayoutInflater.from(context);
            View layout = inflater.inflate(R.layout.toast, null);
            layout.setBackgroundColor(color);
            TextView text = (TextView) layout.findViewById(R.id.text);
            text.setText(msg);
            Toast toast = new Toast(context);
            int yOffset = ThemeUtils.getActionBarHeight(context) + 5;
            toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP, 0, yOffset);
            toast.setDuration(duration);
            toast.setView(layout);
            toast.show();
        } catch (Exception e) {
            Log.e(DEBUG_TAG, "toast failed with " + e.getMessage());
        }
    }
private static void toastTop ( @ NonNull Context context , @ NonNull String msg , int color , int duration ) { try { LayoutInflater inflater = LayoutInflater . from ( context ) ; View layout = inflater . inflate ( R . layout . toast , null ) ; layout . setBackgroundColor ( color ) ; TextView text = ( TextView ) layout . findViewById ( R . id . text ) ; text . setText ( msg ) ; Toast toast = new Toast ( context ) ; int yOffset = ThemeUtils . getActionBarHeight ( context ) + 5 ; toast . setGravity ( Gravity . CENTER_HORIZONTAL | Gravity . TOP , 0 , yOffset ) ; toast . setDuration ( duration ) ; toast . setView ( layout ) ; toast . show ( ) ; } catch ( Exception e ) { Log . e ( DEBUG_TAG , "toast failed with " + e . getMessage ( ) ) ; } }
Display a toast underneath the top action bar
Display a toast underneath the top action bar