Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将浮动操作按钮的customview与Listview最佳匹配_Android_Xml_Android Layout_Listview_Floating Action Button - Fatal编程技术网

Android 如何将浮动操作按钮的customview与Listview最佳匹配

Android 如何将浮动操作按钮的customview与Listview最佳匹配,android,xml,android-layout,listview,floating-action-button,Android,Xml,Android Layout,Listview,Floating Action Button,我有一个带有edittext listview的XML布局和一个包含在linearlayout中的fab,它在屏幕上占据了很大一部分,如果我去掉权重或使用它,我会得到一个非常小的按钮或裁剪 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.andro

我有一个带有edittext listview的XML布局和一个包含在linearlayout中的fab,它在屏幕上占据了很大一部分,如果我去掉权重或使用它,我会得到一个非常小的按钮或裁剪

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:orientation="vertical" android:layout_width="match_parent"
   android:layout_height="match_parent">

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textPersonName"
    android:ems="10"
    android:id="@+id/inputSearch"
    android:hint="Αναζητηση" />

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:layout_margin="4dp">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/listCustomers"
        android:layout_margin="5dp"
        android:dividerHeight="2dp" />
</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="2"
    android:layout_gravity="bottom|center"
    android:gravity="right"
    android:layout_margin="4dp">

    <android.support.design.widget.FloatingActionButton
        android:layout_width="56dp"
        android:layout_height="56dp"
        android:id="@+id/fab"
        app:backgroundTint="@android:color/holo_orange_light"
        android:layout_gravity="bottom|center"
        android:layout_margin="10dp"
        android:src="@drawable/ic_action_cross" />
</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"
android:layout_width="match_parent"
android:layout_height="match_parent">

<EditText
    android:id="@+id/inputSearch"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:hint="Αναζητηση"
    android:inputType="textPersonName" />

<ListView
    android:id="@+id/listCustomers"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/inputSearch"
    android:layout_margin="9dp"
    android:dividerHeight="2dp" />


<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="56dp"
    android:layout_height="56dp"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true"
    android:layout_margin="14dp"
    android:src="@drawable/ic_action_cross"
    app:backgroundTint="@android:color/holo_orange_light" />
</RelativeLayout>

将整个布局替换为以下内容:

<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">

<EditText
    android:id="@+id/inputSearch"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:hint="Αναζητηση"
    android:inputType="textPersonName" />

<ListView
    android:id="@+id/listCustomers"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/inputSearch"
    android:layout_margin="9dp"
    android:dividerHeight="2dp" />


<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="56dp"
    android:layout_height="56dp"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true"
    android:layout_margin="14dp"
    android:src="@drawable/ic_action_cross"
    app:backgroundTint="@android:color/holo_orange_light" />
</RelativeLayout>


Yes看起来不错,但fab按钮覆盖listview项目的文本和图像按钮只需将android:layout_添加到FloatActionButton=“@+id/listCustomers”下面,它不会覆盖它们。Yes看起来不错,但fab按钮覆盖listview项目的文本和图像按钮只需将android:layout_添加到=“@+id/listCustomers”下面将其移动到按钮上,它将不会覆盖它们。