简体   繁体   English

在Android Studio布局编辑器中拖放

[英]Drag and Drop in Android Studio layout editor

I have a problem with adding images to my app's layout. 将图像添加到我的应用布局时出现问题。 I've searched for an answer for a while, but even when doing exactly what friendly people of the internet told me, there is still no success. 我一直在寻找答案,但是即使按照互联网上友好人士告诉我的方式进行,也仍然没有成功。

  • images are in PNG format in res/drawable folder. 图像在res / drawable文件夹中为PNG格式。
  • im trying to drag'n'drop them into the content_*.xml preview. 我试图将它们拖放到content _ *。xml预览中。
  • i can add elements from the palette. 我可以从调色板中添加元素。
  • i am using RelativeLayout. 我正在使用RelativeLayout。

Any idea what may be the cause of this problem? 任何想法可能是此问题的原因吗?

View of my android studio screen: 我的android studio屏幕视图:

一

  1. You must store your images on Drawables folders not in drawable -drawable-hdpi,drawable-mdpi,drawable-xhdpi..... 您必须将图像存储在Drawables文件夹中,而不是drawable -drawable-hdpi,drawable-mdpi,drawable-xhdpi .....

  2. You should drag an ImageView , then add the image with the src param . 您应该拖动ImageView ,然后添加带有src param的图像。 You can't directly drag and drop images 您不能直接拖放图像

  3. You can't add elements in "Palette". 您不能在“调色板”中添加元素。

  4. RelativeLayout ... Okay, whatever layout it's good RelativeLayout ...好吧,无论哪种布局都不错

UPDATE1 UPDATE1

  1. To see the drawable folders you must clic on arrow (see image1) and put on "Project" (image2) 要查看可绘制的文件夹,必须按箭头(参见图1)并放在“项目”(图2)上

一

二

  1. ----------> see point 1. ---------->参见第1点。

  2. Yes you can drag&drop that elemenst, TextViews, ImageViews, Edittext.... 是的,您可以拖放该元素, TextViews, ImageViews, Edittext....

您应该拖动一个ImageView,然后添加带有src参数的图像(可以在右侧菜单或xml中执行此操作)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM