Android 如何使浮动指示器显示在listView的右下角?

Android 如何使浮动指示器显示在listView的右下角?,android,android-layout,Android,Android Layout,如何使浮动指示器显示在列表视图的右下角? 由于某些原因,下面的代码会出现浮动指示或出现在listView的左上角 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/main_layout

如何使浮动指示器显示在列表视图的右下角?

由于某些原因,下面的代码会出现浮动指示或出现在listView的左上角

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/main_layout"
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <include layout="@layout/toolbar_general"/>

    <RelativeLayout android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/contacts_list_view" />

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:layout_margin="@dimen/fab_margin"
            android:src="@android:drawable/ic_dialog_email" />

    </RelativeLayout>

</LinearLayout>

试试这个

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_layout"
android:fitsSystemWindows="true"
android:orientation="vertical">

<include layout="@layout/toolbar_general"/>

<RelativeLayout android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/contacts_list_view" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="10dp"
        android:src="@android:drawable/ic_dialog_email" />

</RelativeLayout>


试试这个

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_layout"
android:fitsSystemWindows="true"
android:orientation="vertical">

<include layout="@layout/toolbar_general"/>

<RelativeLayout android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/contacts_list_view" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="10dp"
        android:src="@android:drawable/ic_dialog_email" />

</RelativeLayout>


问题在于您在floatingActionButton中使用的重力属性。。。 android:gravity设置视图中内容的重力,而不是视图本身。 相反,您应该使用alignParentBottom和alignParentRight属性来获得所需的结果。。。 像这样


希望此帮助…

问题在于您在floatingActionButton中使用的重力属性。。。 android:gravity设置视图中内容的重力,而不是视图本身。 相反,您应该使用alignParentBottom和alignParentRight属性来获得所需的结果。。。 像这样


希望这些帮助…

使用alignParentRight和alignParentBottom使用android:layout\u alignParentBottom=“true”android:layout\u alignParentRight=“true”使用alignParentRight和alignParentBottom使用android:layout\u alignParentBottom=“true”android:layout\u alignParentRight=“true”