2014-02-26 105 views
5

我有三個ImageViews,我想要1 ImageView在背景中,其他2個圖像應該放在那個背景上。我無法使用任何其他視圖,因爲圖像是以無法設置爲LinearRelative佈局背景的圖像形式下載的。Android:在另一個圖像上放置一個圖像

第一影像

enter image description here

這是第二圖像什麼,我想在實際

enter image description here

+0

使用'FrameLayout'滿足您的需求 –

回答

7

你可以試試下面的xml佈局...

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" > 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="@drawable/ic_launcher" 
     android:scaleType="fitXY" /> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginBottom="100dip" 
     android:background="@drawable/ic_launcher" /> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|center_horizontal" 
     android:layout_marginBottom="100dip" 
     android:background="@drawable/ic_launcher" /> 

</FrameLayout> 
1

可以使用這樣的:

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

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 

</FrameLayout> 
1

首先使用佈局relativie在添加圖像視圖,寬度和高度設置爲匹配parent.Then採取第二圖像視圖alignParentTop屬性真對於同樣地,對於第三ImageView的對準其屬性parentbottom寬度和高度設置爲包裹內容真正

1

重疊觀點或塊爲單一商品幀佈局(here)的顯示區域可以被使用。

可以使用

 <FrameLayout 
     android:layout_width="..." 
     android:layout_height="..." 
     android:background="Image1" 
     <ImageView 
      android:layout_width="..." 
      android:layout_height="..." 
      android:background="image2"> 
     <ImageView 
      android:layout_width="..." 
      android:layout_height="..." 
      android:background="image3"> 
    </FrameLayout> 
0

您可以使用層列表中進行layers.xml在繪製 像這樣的事情

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<item> 
    <bitmap android:src="@drawable/img1" 
     android:gravity="center" 
     /> 
</item> 
<item> 
    <bitmap android:src="@drawable/img2" 
     android:gravity="center" 
     /> 
</item> 
</layer-list> 
相關問題