我正在制作一个应用程序,并且已经迁移到 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/