Android 浮动操作按钮内的图标位于右下角,可以';我好像没把它放在中心

Android 浮动操作按钮内的图标位于右下角,可以';我好像没把它放在中心,android,android-layout,Android,Android Layout,我的问题是,我的浮动操作按钮的图标在角落里,而我想它在中心 以下是XML: <?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

我的问题是,我的浮动操作按钮的图标在角落里,而我想它在中心

以下是XML:

 <?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"
    android:background="@android:color/white">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_centerHorizontal="true">

        <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/rv_select">
        </android.support.v7.widget.RecyclerView>

    </LinearLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/create_routine_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_add_black_24dp"
        app:fabSize="normal"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        app:backgroundTint="@color/cardAccent"
        android:layout_margin="10dp"
        app:elevation="10dp" />



</RelativeLayout>

以下是我正在使用的向量(我刚刚使用android studio创建了一个向量):


我在这个问题上花了几个小时,非常感谢您的帮助

编辑:我想出来了。。。我错过了正确的风格

 <item name="floatingActionButtonStyle">@style/Widget.Design.FloatingActionButton</item>
@style/Widget.Design.FloatingActionButton
使用此代码

1> 实现这种依赖

实现'com.google.android.material:material:1.0.0-alpha1'

2>


使用此代码

1> 实现这种依赖

实现'com.google.android.material:material:1.0.0-alpha1'

2>




您的代码工作得非常完美……我已经尝试了您的代码,它看起来很好,没有任何问题。显示您的完整xml文件。@ChiragRaval编辑的PostTested,工作正常。这没什么问题。@AndrewP只是为了测试:从矢量中删除android:autoMirrored=“true”您的代码工作得很好……我已经尝试了您的代码,看起来很好,没有问题。显示您的完整xml文件。@ChiragRaval编辑的PostTested,工作正常。这没什么问题。@AndrewP只是为了测试:从矢量中删除android:autoMirrored=“true”当我使用app:srccomat时,按钮消失了,尽管我已经编辑了代码段,请尝试使用它。这对我很有用,你使用的是哪个版本的依赖项?我使用的是实现'com.android.support:design:26.1.0',当我使用app:srccomat时,按钮会消失,尽管我已经编辑了代码片段,请尝试使用它。这是我的工作,您使用的是哪个版本的依赖项?我使用的是实现'com.android.support:design:26.1.0'
 <item name="floatingActionButtonStyle">@style/Widget.Design.FloatingActionButton</item>
<com.google.android.material.floatingactionbutton.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"
    app:srcCompat="@drawable/vec_file" />
  <android.support.design.widget.FloatingActionButton
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="bottom|right"
  android:layout_margin="16dp"
  app:fabSize="normal"
  app:srcCompat="@drawable/ic_add_black_24dp"
  tools:ignore="VectorDrawableCompat"
  />

//vectore file 
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24.0"
    android:viewportHeight="24.0">
<path
    android:fillColor="#ffffffff"
    android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>