Home > front end >  ImageButton not visible on some devices Android Studio
ImageButton not visible on some devices Android Studio

Time:06-08

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. This is my xml code:

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

CodePudding user response:

I tried changing app:srcCompat to android:src, which did not work. 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. So, I changed the resolution of the image to 600x600 px and that did the trick.

(I didn't find this solution for this specific problem anywhere online, so I decided to share it here.)

  • Related