2014-10-27 75 views
0

我希望你很好。如何将图像添加到android studio中的空白活动?

首先,道歉,如果这似乎是一个愚蠢的问题,但有人可以解释我怎么可以在Android工作室的空白活动添加图像?

我正在使用API​​版本19,并在新项目中创建了一个空白活动。我有一张我想用PNG格式的图片,它有一个透明背景。

感谢,

保罗

+0

'Imageview' ...? – codeMagic 2014-10-27 14:24:08

+0

这就是我曾尝试的,但它不让我浏览图像? – Smithey93 2014-10-27 14:26:00

+0

将根视图的背景设置为图像或将ImageView添加到根,并在其中使用图像。 – reactivemobile 2014-10-27 14:26:23

回答

0

http://developer.android.com/reference/android/widget/ImageView.html

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent"> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:src="@drawable/img_swoosh_image" /> 
</RelativeLayout> 

您可能需要的LinearLayout或FrameLayout里这取决于你想展示还有什么用。

+1

*“您可能想要使用LinearLayout或FrameLayout”*为什么只有这两个? – codeMagic 2014-10-27 14:27:11

+0

在我的答案中已经提到了RelativeLayout。 – James 2014-10-27 15:08:41

0

1)使用可以在设计选项卡访问的ImageView的,

2)将图像粘贴(说

3)后面的“xyz.png”)到项目的绘制文件夹ImageView的属性部分,在src属性中为“@ drawable/xyz.png”

4)一切顺利!希望它有帮助。

相关问题