2012-02-29 154 views
1

在我的項目中,我有一個菜單。對於我想要使用gridView的菜單設計。爲簡單起見,假定此網格視圖只有一個項目。這個項目有兩個獨立的圖像(background.png和news.png)和一個文本(例如「NEWS」)。Android,如何將圖片放在另一張圖片上?

是否可以通過xml或代碼將background.png上的news.png映射到background.png上?

感謝您的幫助。

+0

你想顯示兩個圖像在另一個... – 2012-02-29 05:11:51

+0

是的,我想知道它是否實用? – Hesam 2012-02-29 05:46:25

+0

@Hesam你有沒有找到任何解決方案> – PriyankaChauhan 2016-11-02 10:29:14

回答

1

是的你可以隨時使用FrameLayout在xml文件中,像這樣。

<FrameLayout android:id="@+id/frameLayout1" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <ImageView android:id="@+id/imageView1" android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:src="@drawable/background"></ImageView> 
    <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" 
     android:layout_gravity="center" android:layout_height="wrap_content" 
     android:src="@drawable/news"></ImageView> 
    <TextView android:text="NEWS" android:id="@+id/textView1" android:layout_gravity="bottom|center_horizontal" 
     android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 
</FrameLayout> 
+0

或者你可以設置父母佈局的android:background屬性(但它會擴展到佈局大小)。 – Sver 2012-02-29 05:52:13

+0

@Sver你的意思是說採取佈局設置背景,並在該線性佈局採取imageview和textview?..是的,可以工作..可能不看好編程,但可以實現相同的結果。 – MKJParekh 2012-02-29 05:57:03

+0

好吧,如果背景圖像只是簡單的背景圖像沒有太多細節..爲什麼不呢?在FrameLayout的情況下,您需要考慮圖像的大小。 – Sver 2012-02-29 06:01:15

相關問題