How can I spawn an Android crouton from the bottom?

1.3k Views Asked by At

I am using keyboardsurfer's crouton library as a replacement for toasts. I am curious if there is an easy way to spawn the crouton from the bottom rather than the action bar. I looked at Configuration but didn't notice anything that would help me.

2

There are 2 best solutions below

1
On BEST ANSWER

See: https://github.com/keyboardsurfer/Crouton/issues/84 which leads to https://github.com/keyboardsurfer/Crouton/pull/132 which leads to https://github.com/keyboardsurfer/Crouton/issues/169 :(

In short: not available yet but you'd simply need to take the proposed pull request and format it to the new Android Studio source tree structure.

0
On

You can create an empty LinearView in your activity xml file and make it as a footer. Make sure to set it's visibility as gone. Something like below:

<LinearLayout
           android:id="@+id/croutonview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="bottom" >

  </LinearLayout>

Then call the crouton.makeText() with an extra parameter having this linearview's resource id. Something like this:

Crouton.makeText( this, "crouton message" de.keyboardsurfer.android.widget.crouton.Style.INFO,(ViewGroup)findViewById(R.id.croutonview)) .show();

Hope it helps!