【问题标题】:Showing Image in ImageButton在 ImageButton 中显示图像
【发布时间】:2020-06-03 17:51:59
【问题描述】:

我在 ImageButton 中添加了一个图像,但它没有显示。为什么?

 <ImageButton
        android:id="@+id/next_button"
        android:layout_width="105dp"
        android:layout_height="53dp"
        android:src="@drawable/icons8-fast-forward-64" 
        android:contentDescription="@string/next_text" />

【问题讨论】:

  • @drawable/icons8-fast-forward-64 这是图片位置吗?
  • 如果您发现我的答案是正确的,我可以请您单击答案左侧的勾号表示它是正确的。有关当有人回答您的问题时该怎么做的更多信息,请单击此处:stackoverflow.com/help/someone-answers

标签: android android-studio imagebutton android-imagebutton


【解决方案1】:

问题在于您对可绘制对象的命名......

将其重构为从icons8-fast-forward-64 读取icons8fastforward64

<ImageButton
        android:id="@+id/next_button"
        android:layout_width="105dp"
        android:layout_height="53dp"
        android:src="@drawable/icons8fastforward64" 
        android:contentDescription="@string/next_text" />

【讨论】:

    【解决方案2】:

    您的代码看起来不错,请检查您的 drawable 资源。它是否显示在xml 布局文件中??

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-25
      • 1970-01-01
      • 2014-09-05
      • 2014-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多