在设计界面时,我插入了几个xml格式的图片。但是一运行就崩溃,手机上直接闪退,模拟器显示unfortunately your application has stopped。插入图片的代码见下图。

        <ImageButton
            android:id="@+id/ibRegularService"
            android:layout_width="0dp"
            android:layout_height="@dimen/activity_image_buttons"
            android:layout_weight="1"
            android:backgroundTint="@color/colorBlue"
            android:src="@drawable/emoticon_sad_outline"/>

我已经将xml文件放在res->drawable v24中了。在网上看到说有可能是图片太大,或者配置文件缺失。我的图片非常小,第一项排除了。
安卓无法使用图片,报错Resource emoticon is not a Drawable
去file->setting->sdk下载了android 6.0的API和如图所示的工具安卓无法使用图片,报错Resource emoticon is not a Drawable
但是运行时仍然报错,第二项排除。在stackoverflow上看到大神的评论,旧的安卓api不支持直接放在drawable v24中,需要放在drawable中。安卓无法使用图片,报错Resource emoticon is not a Drawable
复制一份到drawable后成功运行:)

相关文章:

  • 2022-12-23
  • 2022-01-18
  • 2021-08-07
  • 2022-12-23
  • 2021-10-25
  • 2021-10-03
  • 2021-12-11
  • 2022-01-23
猜你喜欢
  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案