【问题标题】:Why does FAB appear different on different Android devices/OS versions?为什么 FAB 在不同的 Android 设备/操作系统版本上出现不同?
【发布时间】:2017-11-29 06:03:20
【问题描述】:

谁能告诉我为什么完全相同的图像(与 PNG 相同的图像资源文件,以及下面相同的 XML 定义)在 Android 5.1 和 7.1.1(上图)上看起来很完美,但在 Android 4.1 上看起来很糟糕(下图) .

上面的图像在以下情况下看起来很完美: 三星真机5.1 像素 API 25 (7.1.1) 模拟器

下面的图片看起来很糟糕: 三星真机4.3 Nexus One API 18 4.2 模拟器

XML 代码:

<android.support.design.widget.FloatingActionButton
    android:id="@+id/myFAB"
    android:layout_width="75dp"
    android:layout_height="75dp"
    android:layout_gravity="center|bottom"
    android:layout_margin="@dimen/fab_margin"
    android:visibility="invisible"/>

请告诉我如何解决这个问题。

编辑:图像是从 Android Studio“新图像资产”生成的,并且确实生成了不同的分辨率(hdpi、mdpi、xhdpi、xxhdpi)。

【问题讨论】:

    标签: java android android-layout material-design floating-action-button


    【解决方案1】:

    FloatingActionButton 不能采用任何宽度/高度。 app:fabSize 参数为 fab 指定 3 种尺寸:auto、mini 和 normal。

    layout_widthlayout_height 保留为wrap_content,并使用app:fabSize="normal"(或列表中的其他参数)指定所需的晶圆厂尺寸。

    【讨论】:

      猜你喜欢
      • 2011-07-18
      • 1970-01-01
      • 1970-01-01
      • 2018-05-27
      • 1970-01-01
      • 2021-06-03
      • 2020-01-24
      • 1970-01-01
      • 2016-01-16
      相关资源
      最近更新 更多