java - 将图像添加到 Android Studio 1.3.1 项目

标签 java android image

我正在制作一个应用程序,并且已经迁移到 Android Studio 1.3.1,因为它最近有了很大改进。我的 activity_main.xml 中有一行 ImageButtons。然后我右键单击 drawable 文件夹,选择 NewImageAsset。我尝试了 Assets 类型启动器图标操作栏和选项卡图标通知图标并选择了图像。 Android Studio 渲染图像的 hdpi、mdpi、xhdpi 和 xxhdpi 版本。

但是 android:src="@drawable/backwardImage 仍然给我无法解析 android:src="@drawable/backwardImage"

如何在 android Studio 1.3.1 中执行此操作?我很确定有一个非常简单的答案。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_weight=".10"
        android:orientation="horizontal">
        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/backwardImage"
            android:id="@+id/imageButton01"/>
        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/backwardImage"
            android:id="@+id/imageButton02"/>
        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/backwardImage"
            android:id="@+id/imageButton03"/>
    </LinearLayout>

问候,

托马斯

最佳答案

我没有尝试过你的方法。

使用资源管理器,转到源代码,将我的图像粘贴到可绘制文件夹中。进入Android studio,你会看到图像(与drawable-xhdpi等相同)

另一种方法是将图像从资源管理器拖动到 Android studio 中的可绘制对象中。

注意:您的图像应该是 png 或 jpg。希望这有帮助!

关于java - 将图像添加到 Android Studio 1.3.1 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32157901/

相关文章:

java - Keycloak 适配器 pkix 路径构建失败

java - 通过 Google 的 API 共享 Google 日历

android - Android 设备上的 RTSP 服务器的可能性?

android - 更新后 Gradle 同步失败

android - 显示图像的名称( Kotlin )

css - CSS : is there a webkit alternative for -moz-crisp-edges? 图像缩放

Java:类似 Javascript 的分割行为

java - 如何在 Hibernate 中用 TableGenerator 替换已弃用的 MultipleHiLoPerTableGenerator

android - MenuItem.mActionProvider 为空

c# - 哪些图标/图像可以直接使用 .NET Framework 类?