简体   繁体   English

ImageButton 在某些设备 Android Studio 上不可见

[英]ImageButton not visible on some devices Android Studio

I use an ImageButton in my android studio project and the image (png) is visible on almost all devices I tested the app, but on my older phone it is invisible, but still clickable tho.我在我的 android studio 项目中使用了 ImageButton,并且图像(png)在我测试应用程序的几乎所有设备上都可见,但在我的旧手机上它是不可见的,但仍然可以点击。 This is my xml code:这是我的 xml 代码:

<ImageButton
        android:id="@+id/ib_settings"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_below="@+id/ib_end"
        android:layout_alignParentEnd="true"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="15dp"
        android:background="@null"
        android:scaleType="fitCenter"
        app:srcCompat="@drawable/imgsettings"
        tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" />

I tried changing app:srcCompat to android:src , which did not work.我尝试将app:srcCompat更改为android:src ,但没有成功。 Then I noticed that the PNG I was using as an image source is 2000x2000 px, which is quite a lot if you want to resize it to 40x40dp.然后我注意到我用作图像源的 PNG 是 2000x2000 像素,如果您想将其调整为 40x40dp,这将是相当多的。 So, I changed the resolution of the image to 600x600 px and that did the trick.因此,我将图像的分辨率更改为 600x600 像素,这样就成功了。

(I didn't find this solution for this specific problem anywhere online, so I decided to share it here.) (我在网上的任何地方都没有找到这个特定问题的解决方案,所以我决定在这里分享。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM