带有ListView的FAB未显示



我的应用中有一个未显示的晶圆厂。

我遵循了一个教程,并在(XML)中做了他所做的。但是在他的屏幕截图上,我可以看到晶圆厂,但是当屏幕上的列表中有视图时,它不会显示出来。如果只有一个视图/行或行没有行,并且有一些fab可以显示的空间,则它会显示出来。

我认为我的Layout XML有问题。

任何人都可以告诉我哪里出错了。

谢谢。

XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="10sp"
        >
        <Button
            android:id="@+id/buttonAA"
            android:layout_width="wrap_content"
            android:layout_height="25sp"
            android:background="@drawable/buttondesign"
            android:textColor="@color/white"
            android:layout_weight="0.5"
            android:text="Hide Arabic" />
        <Button
            android:id="@+id/buttonRA"
            android:layout_width="wrap_content"
            android:layout_height="25sp"
            android:background="@drawable/buttondesign"
            android:layout_marginStart="10sp"
            android:textColor="@color/white"
            android:layout_weight="0.5"
            android:text="Hide Reference" />
    </LinearLayout>

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </ListView>
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/floating_action_button_fab_with_listview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:layout_marginEnd="16dp"
        android:clickable="true"
        android:src="@drawable/ic_fav"
        app:elevation="4dp" />
</LinearLayout>

尝试此

<?xml version="1.0" encoding="utf-8"?>
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.nimblechapps.awesomefont.MainActivity">
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:orientation="vertical">
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="10sp"
            >
            <Button
                android:id="@+id/buttonAA"
                android:layout_width="wrap_content"
                android:layout_height="25sp"
                android:background="@drawable/buttondesign"
                android:textColor="@color/white"
                android:layout_weight="0.5"
                android:text="Hide Arabic" />
            <Button
                android:id="@+id/buttonRA"
                android:layout_width="wrap_content"
                android:layout_height="25sp"
                android:background="@drawable/buttondesign"
                android:layout_marginStart="10sp"
                android:textColor="@color/white"
                android:layout_weight="0.5"
                android:text="Hide Reference" />
        </LinearLayout>

        <ListView
            android:id="@+id/list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </ListView>
    </LinearLayout>
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/floating_action_button_fab_with_listview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginEnd="16dp"
        android:clickable="true"
        android:src="@drawable/ic_fav"
        app:elevation="4dp" />
   </RelativeLayout>

也许浮动动作按钮在列表视图下方。您必须尝试一下。

findViewById(R.id.floating_action_button_fab_with_listview).bringToFront();