这是我的xml。我希望避免图形布局中的图像之间存在间隙。我希望所有图像彼此对齐,使得5幅图像看起来像一张图像。
<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 :(得分:0)
尝试从父线性布局中删除此行android:layout_margin="5dp"
答案 1 :(得分:0)
设置
layout_width="0dp"
所有图片并删除
android:weightSum="5"
如果所有图像大小相同,那么这是正确的:
android:layout_height="wrap_content"
如果尺寸不同,则很难正确对齐它们,但设置固定尺寸可能会有所帮助。
答案 2 :(得分: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>
我刚刚使用framelayout放置了4个重叠的图像。我刚刚给marginLeft
表明了这一点
图像实际上就在那里。