2014-10-27 73 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)一切順利!希望它有幫助。

相關問題