简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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