Ich bin mit dem SupportSnackbar mit CoordinatorLayout deaktivieren entlassen
- FloatingActionButton
- Snackbar
- CoordinatorLayout
Ich brauche die CoordinatorLayout so, dass, wenn SnackBar ist die gezeigt FloatingActionButton bewegt sich um Platz für die Snackbar zu machen. Zum besseren Verständnis überprüfen Sie diese video.
Ich benutze SnackBar für Double-Back, um die Anwendung zu beenden, aber die SnackBar kann entlassen werden.
Gibt es eine Möglichkeit, die Kündigung auf der SnackBar zu deaktivieren?
Snackbar snackbar = Snackbar.make(view, R.string.press_back_again_to_exit, Snackbar.LENGTH_SHORT);
snackbar.setAction(R.string.ok, new View.OnClickListener() {
@Override
public void onClick(View v)
{
}
});
snackbar.setActionTextColor(getResources().getColor(R.color.white));
View view = snackbar.getView();
view.setBackgroundColor(getResources().getColor(R.color.orange_warning));
snackbar.show();
Layout-
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:fitsSystemWindows="true">
<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoFadeColor="@android:color/transparent"
sothree:umanoPanelHeight="100dp"
sothree:umanoShadowHeight="4dp">
<!-- Toolbar and main content -->
<LinearLayout
android:id="@+id/toolbar_and_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/toolbar"/>
<!-- Your content layout -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
</LinearLayout>
<!-- Sliding up panel layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/darker_grey"
android:orientation="vertical">
...
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
<!-- Navigation drawer -->
<ExpandableListView
android:id="@+id/lv_left_drawer"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/white"
android:childDivider="@android:color/transparent"
android:clickable="true"
android:divider="@color/divider_color"
android:dividerHeight="0.6dp"
android:fadeScrollbars="true"
android:groupIndicator="@null"
android:listSelector="@drawable/button_drawer_child_selector"
android:scrollbarSize="0dp"/>
</android.support.v4.widget.DrawerLayout>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|bottom"
android:layout_marginBottom="@dimen/floating_action_button_margin"
android:layout_marginRight="@dimen/floating_action_button_margin"
android:src="@drawable/ic_add"
android:visibility="invisible"
app:backgroundTint="@color/orange"
app:borderWidth="0dp"
app:elevation="6dp"
app:fabSize="normal"/>
</android.support.design.widget.CoordinatorLayout>
P. S.
Ich bin bewusst, this GitHub library, die diese Funktionalität hat, aber gibt es eine "native" Möglichkeit, es zu tun?
Ich denke, es gibt keinen Weg –
* I SnackBar für Doppel zurück bin mit der Anwendung * zu verlassen - Sie gehen gegen die UI-Muster der Plattform. SnackBars sind für kleines Feedback und nicht um den Benutzer nach Aktion zu fragen (wie ich annehme, Sie versuchen zu tun, wenn der Benutzer zweimal drückt) – Luksprog
@Luksprog Ich bin mir dessen bewusst, das gleiche könnte mit einem Toast oder einem erreicht werden Crouton, aber es ist im Grunde das Gleiche, SnackBar sieht einfach schöner aus. Ich bin persönlich kein Fan von Double-Back zu verlassen, aber leider ist es nicht für mich zu entscheiden. – Marko