Ich habe eine AppCompatActivity mit einem Listview mit dem Layout unterEmptyView von Listview versteckt BottomNavigationView
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/user_title"
android:background="@drawable/user_title_color"
android:textColor="@android:color/white"
android:textAppearance="@android:style/TextAppearance.Large"/>
<ListView android:id="@+id/joggings_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:divider="#b5b5b5"
android:dividerHeight="1dp"
android:drawSelectorOnTop="false"/>
<LinearLayout
android:id="@+id/empty_list"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center">
<TextView
android:text="No joggings yet"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/empty_add_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_jogging"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/bottom_navigation"
android:layout_alignParentRight="true"
android:layout_gravity="end|bottom"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:clickable="true"
android:src="@drawable/ic_plus"
app:borderWidth="0dp" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/colorPrimaryDark"
android:foregroundTint="@color/colorAccent"
app:itemTextColor="@color/bottom_navigation_color"
app:itemIconTint="@color/bottom_navigation_color"
app:menu="@menu/bottom_navigation_main" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
und in meinem Code ich habe mListView.setEmptyView (findViewById (R.id.empty_list));
um eine Nachricht und eine Schaltfläche "Hinzufügen" anzuzeigen, wenn die Liste leer ist. Mein Problem ist, dass die BottomNavigationView ausgeblendet ist und der Benutzer nicht zu einer anderen Aktivität navigieren kann, wenn die Liste leer ist.
Eine mögliche Lösung, die ich mir vorstellen kann, ist das Hinzufügen einer anderen BottomNavigationView mit den gleichen Elementen im leeren Layout, aber das scheint hässlich.
Jede andere Lösung?
Scheint ein Layout, um Problem zu sein, Ihre BottomNavigationView vom Bildschirm abgezogen, so dass eine mögliche Lösung eine relative Layout zu verwenden ist als direkte Schwester des Koordinators, um sicherzustellen, dass alle Ansichten auf den Bildschirm passen. –