为什么FAB在不同的Android设备/操作系统版本上看起来有所不同? [英] Why does FAB appear different on different Android devices/OS versions?
问题描述
谁能告诉我,为什么完全相同的图像(与PNG相同的图像资源文件,以及下面的XML定义)在Android 5.1和7.1.1(上图)上看起来完美,而在Android 4.1(下图)上却不好?
Can anyone tell me why exactly the same image (same image resource file as PNG, and same XML definition below) looks perfect on Android 5.1 and 7.1.1 (the image above) but bad on Android 4.1 (the image below).
上面的图像在以下情况下看起来很完美: 三星实机5.1 Pixel API 25(7.1.1)模拟器
The above image appears perfect on: Samsung real device 5.1 Pixel API 25 (7.1.1) emulator
下面的图片看起来很糟糕: 三星真实设备4.3 Nexus One API 18 4.2模拟器
The below image looks bad on: Samsung real device 4.3 Nexus One API 18 4.2 emulator
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"/>
请提出如何解决此问题的建议.
Please advice how can I fix this problem.
图像是从Android Studio新图像资产"生成的,并且确实生成了不同的分辨率(hdpi,mdpi,xhdpi,xxhdpi).
the images were generated from Android Studio "New Image Asset" and different resolutions (hdpi, mdpi, xhdpi, xxhdpi) has indeed been generated.
推荐答案
FloatingActionButton
不能采用任何宽度/高度. app:fabSize
参数为fab指定3种尺寸:自动,迷你和常规.
FloatingActionButton
cannot take any width/height. app:fabSize
parameters specifies 3 sizes for the fab: auto, mini, and normal.
将layout_width
和layout_height
保留为wrap_content
,并使用app:fabSize="normal"
(或列表中的其他参数)指定所需的晶圆厂大小.
Leave layout_width
and layout_height
as wrap_content
, and specify the desired fab size using app:fabSize="normal"
(or other parameter from the list).
这篇关于为什么FAB在不同的Android设备/操作系统版本上看起来有所不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!