nispok/snackbar

Snackbar text aligned to top with multiline

emartynov opened this issue · 5 comments

Please take a look to the screenshot:
2015-03-25_11_38_47

The sample app works as expected. I'm trying to find the cause. If you have any ideas please share.

wmora commented

lib version? Could you share the code where you create the Snackbar?

Here is line from gradle:

  compile 'com.nispok:snackbar:2.10.2'

Here is code how we do show it:

    public void showInfoSnackbar( @NonNull final Context context, int message, ActionClickListener actionClickListener,
                                  final View floatingActionButton )
    {
        com.nispok.snackbar.Snackbar snackbar = getDefaultSnackbar( context, message );
        if ( actionClickListener != null )
        {
            snackbar.actionListener( actionClickListener );
        }

        if ( floatingActionButton != null )
        {
            snackbar.eventListener( new EventListener()
            {
                @Override
                public void onShow( com.nispok.snackbar.Snackbar snackbar )
                {
                    AnimationHelper.moveVerticallyTo( floatingActionButton, snackbar.getHeight(), 200 );
                }

                @Override
                public void onShowByReplace( com.nispok.snackbar.Snackbar snackbar )
                {

                }

                @Override
                public void onShown( com.nispok.snackbar.Snackbar snackbar )
                {

                }

                @Override
                public void onDismiss( com.nispok.snackbar.Snackbar snackbar )
                {
                    int marginBottom =
                        (int) context.getResources().getDimension( R.dimen.floating_action_button_margin );
                    AnimationHelper.moveVerticallyTo( floatingActionButton, marginBottom, 200 );
                }

                @Override
                public void onDismissByReplace( com.nispok.snackbar.Snackbar snackbar )
                {

                }

                @Override
                public void onDismissed( com.nispok.snackbar.Snackbar snackbar )
                {

                }
            } );
        }
        SnackbarManager.dismiss();
        SnackbarManager.show( snackbar );
    }

    private com.nispok.snackbar.Snackbar getDefaultSnackbar( @NonNull Context context, int message )
    {
        String text = context.getString( message );
        com.nispok.snackbar.Snackbar snackbar = com.nispok.snackbar.Snackbar.with( context ).text( text );
        snackbar.actionLabel( context.getString( R.string.OK ) );
        snackbar.actionColor( context.getResources().getColor( R.color.orange ) );
        snackbar.duration( com.nispok.snackbar.Snackbar.SnackbarDuration.LENGTH_INDEFINITE );
        snackbar.color( context.getResources().getColor( R.color.snackBar_background ) );
        if ( !StringUtils.textFitsScreenWidth( context, text, VersionHelper.getValueAsDensityPixels( 16, context ),
                                               VersionHelper.getValueAsDensityPixels( 70, context ) ) )
        {
            snackbar.type( SnackbarType.MULTI_LINE );
        }
        return snackbar;
    }

Context is activity. Which has RelativeLayout container with Toolbar, FAB and FrameLayout

More insides:

2015-03-25_18_06_56

I've updated to latest version and text is centred now. Looks like one of changes eventually fixed my issue. Thank you!