2012-12-12 17 views
0

這是我的xml。我想要避免的圖形佈局中的圖像之間存在間隙。我希望所有圖像都以這樣一種方式彼此對齊,以使5幅圖像看起來像一幅圖像。如何使用ImageViews將五個圖像相互連接在一起?

<LinearLayout 
    android:id="@+id/linearInteractTab" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 

    android:layout_centerHorizontal="true" 
    android:weightSum="5" 
    android:layout_margin="5dp" > 

    <ImageView 
     android:id="@+id/imgCall" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:src="@drawable/call" /> 

    <ImageView 
     android:id="@+id/imgMsg" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/mail" /> 

    <ImageView 
     android:id="@+id/imgComment" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/chat" /> 

    <ImageView 
     android:id="@+id/imgDir" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/direction" /> 

    <ImageView 
     android:id="@+id/imgAppt" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/calender" /> 
</LinearLayout> 
+0

使用'framelayout'而不是'linearlayout'。這樣圖像就會重疊在一起。 :) – Chaitanya

+0

你試過了,然後給了一個soln? – ParijatDev

+0

是的..它沒有爲我花花公子:)只需將linearlayout替換爲framelayout即可。這爲我做了。只有圖像會重疊。 :) – Chaitanya

回答

0

嘗試從母體線性佈局

+0

沒有做任何事情好你的答案.... – ParijatDev

+1

然後可能是你的形象可能有外部空間。請檢查它或嘗試將layout_width設置爲所有Imageviews的0dp。 – Shrikant

+0

不,它沒有任何空間........ – ParijatDev

0

layout_width="0dp" 

去除該線android:layout_margin="5dp"爲所有圖像和除去

android:weightSum="5" 

如果所有圖像是相同的尺寸,然後該是正確的:

android:layout_height="wrap_content" 

如果尺寸不同,將很難正確對齊它們,但設置固定的尺寸可能會有所幫助。

0
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="5dp" 
    android:weightSum="5" > 

    <ImageView 
    android:id="@+id/imgComment" 
    android:layout_width="fill_parent" 
    android:layout_marginLeft="10dp" 
    android:layout_height="wrap_content" 
    android:src="@drawable/ic_launcher" /> 
    <ImageView 
    android:id="@+id/imgComment" 
    android:layout_width="fill_parent" 
    android:layout_marginLeft="20dp" 
    android:layout_height="wrap_content" 
    android:src="@drawable/ic_launcher" /> 

    <ImageView 
    android:id="@+id/imgComment" 
    android:layout_width="fill_parent" 
    android:layout_marginLeft="30dp" 
    android:layout_height="wrap_content" 
    android:src="@drawable/ic_launcher" /> 

    </FrameLayout> 

我剛剛放置了4個使用framelayout重疊的圖像。我剛剛給marginLeft顯示 圖像實際上存在。