android - float 操作按钮图标不在中心

标签 android xml android-layout floating-action-button

没有other answers在 SO 上帮助了我。

这是我的 FAB xml:

<com.google.android.material.floatingactionbutton.FloatingActionButton xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/fabTransfer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    app:fabCustomSize="@dimen/fab_size_normal"
    android:layout_margin="16dp"
    app:srcCompat="@drawable/ic_add_white_24dp" />

这是图标 xml:

<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>

然而我的图标看起来像这样!

enter image description here

有什么想法吗?我也尝试过使用其他图标(png 和矢量),但还是一样。

最佳答案

正在关注 this answer您应该尝试将 app:fabCustomSize 设置为 24dp 并查看它是否工作得更好。

关于android - float 操作按钮图标不在中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55615709/

相关文章:

microsoft-metro - 我想为我的 android 应用程序设计一个 metro 风格的用户界面

java - 需要帮助将链接列表实现到 TableView javaFX 并将其保存到文件中

android - MaterialSearchView android中的OnClick项目选择

android - 无法在我的自定义 ArrayAdapter 中访问 R.layout.mylayoutname

android - 使用 Jack 时未生成 Dagger 2 组件

android - 在为 Android 构建 V8 javascript 引擎时,我不断收到 "[...]/bin/*-ar: not found"错误

JSONObject 的 java.lang.NullPointerException 错误

java - XML 包装器 JSON 格式问题

java - 如何使用 XSL 排列数据

安卓微调器 : center text vertically within spinner