Hier ist eine einfache Art und Weise SnackBar mit CoordinatorLayout in-Code enthalten sein hinzufügen oben auf dem Bildschirm, aber die Animation ist immer noch ein Problem.
einfach ein CoordinatorLayout Layout zum Layout wie hinzufügen:
<android.support.design.widget.CoordinatorLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:id="@+id/snackbarlocation">
</android.support.design.widget.CoordinatorLayout>
und dann in Ihrer Aktivität erhalten einen Verweis auf sie und geben sie an die SnackBar wie folgt:
CoordinatorLayout Clayout = (CoordinatorLayout)findViewById(R.id.snackbarlocation);
FabButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Snackbar.make(Clayout, "This snack bar located at top", Snackbar.LENGTH_SHORT).show();
}
});
Credits
müssen Sie auch andere Animationen einfügen. in_form_top und out_to_top. Überprüfen Sie diese http://StackOverflow.com/a/33333521/1031297 – OWADVL