【问题标题】:Where Should I put the PNG file relate to ImageButton in Android?我应该将与 Android 中的 ImageButton 相关的 PNG 文件放在哪里?
【发布时间】:2011-03-03 11:53:33
【问题描述】:

我对 Android 很陌生。

我创建了一个 ImageButton。 main.xml 包含如下代码段。

<ImageButton
android:id="@+id/button1"
android:layout_width="50px"
android:layout_height="50px"
android:src="@drawable/cat"
android:layout_x="50px"
android:layout_y="52px"
>

我必须把我拥有的“cat.png”放在哪里。我需要将其重命名为其他名称吗?

【问题讨论】:

标签: android imagebutton


【解决方案1】:

将它放在你的 Android 项目的res/drawable/ 文件夹中。保留名称 cat.png

【讨论】:

  • 有 3 个文件夹。可绘制-hdpi、可绘制-ldpi、可绘制-mdpi?我需要把它放在所有 3 上吗?还是我需要更改xml代码?
  • 这取决于您是否希望它为不同的屏幕 dpi 提供不同的分辨率。将其设为 hdpi 为 240dpi、mdpi 为 160dpi、ldpi 为 120dpi 的高分辨率图像。
【解决方案2】:

您可以简单地将其放入任何一个文件夹中,无需为此更改 xml。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-22
    • 2016-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-21
    相关资源
    最近更新 更多