在某些设备Android Studio上不可见ImageButton
我在我的Android Studio项目中使用imageButton,并且在我测试了该应用程序的几乎所有设备上都可以看到Image(PNG),但是在我的旧手机上,它是看不见的,但仍然可以单击。这是我的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 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" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我尝试将不起作用的
应用程序:srccompat
更改为android:src
。然后,我注意到我用作图像源的PNG为2000x2000 PX,如果您想将其调整到40x40dp,那将是很多。因此,我将图像的分辨率更改为600x600 PX,这是解决问题的。(我在网上任何地方都没有找到这个特定问题的解决方案,所以我决定在这里分享。)
I tried changing
app:srcCompat
toandroid: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.)