2014-12-03 43 views
0

我想添加一些社交图像在我的应用程序关于我的屏幕,但我面临的问题是在图像浏览之间给出相等的空间。给ImageViews之间的平等空间

我的图片看起来是这样的:

see screenshot

,但我想,使它们看起来就像这样:

see screenshot

我的代码:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/RelativeLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/about_screen" > 

    <LinearLayout 
     android:id="@+id/llSocialMediaContainer" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:orientation="horizontal" 
     android:paddingBottom="@dimen/bottum_padding" > 

     <!-- Facebook --> 

     <ImageView 
      android:layout_width="@dimen/social" 
      android:layout_height="@dimen/social" 
      android:src="@drawable/facebook" /> 

     <!-- Twitter --> 

     <ImageView 
      android:layout_width="@dimen/social" 
      android:layout_height="@dimen/social" 
      android:src="@drawable/twitter" /> 

     <!-- Google+ --> 

     <ImageView 
      android:layout_width="@dimen/social" 
      android:layout_height="@dimen/social" 
      android:src="@drawable/google" /> 

     <!-- Linkedin --> 

     <ImageView 
      android:layout_width="@dimen/social" 
      android:layout_height="@dimen/social" 
      android:src="@drawable/linkedin" /> 

     <!-- Blog --> 

     <ImageView 
      android:layout_width="@dimen/social" 
      android:layout_height="@dimen/social" 
      android:src="@drawable/blog" /> 

     <!-- Youtube --> 

     <ImageView 
      android:layout_width="@dimen/social" 
      android:layout_height="@dimen/social" 
      android:src="@drawable/youtube" /> 

     <!-- Email --> 

     <ImageView 
      android:layout_width="@dimen/social" 
      android:layout_height="@dimen/social" 
      android:src="@drawable/mail" /> 
    </LinearLayout> 

</RelativeLayout> 
+0

设置每张图片浏览量的余量 – 2014-12-03 09:43:01

回答

3

你去那里,相应地修改代码,了解android:layout_weight它是有用的在这种情况下:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <ImageView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 

    <ImageView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 

    <ImageView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 

    <ImageView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 

    <ImageView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" /> 

</LinearLayout> 
0

集layout_margin imageview的属性给空间是吐温thos图像视图。

0

使用<Space/>在imageviews之间你的LinearLayout元素添加平等的空间。您可以使用LinearLayouts的weight属性来分配宽度,以获得所有不同形状因子的等距图标。

实施例:

<LinearLayout 
     android:id="@+id/llSocialMediaContainer" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:orientation="horizontal" 
     android:paddingBottom="@dimen/bottum_padding" > 

     <!-- Facebook --> 

     <ImageView 
      android:layout_width="@dimen/social" 
      android:layout_height="@dimen/social" 
      android:src="@drawable/facebook" /> 

     <Space 
      android:layout_width="15dp" 
      android:layout_height="match_parent"/> 
     <!-- Twitter --> 

     <ImageView 
      android:layout_width="@dimen/social" 
      android:layout_height="@dimen/social" 
      android:src="@drawable/twitter" /> 

</LinearLayout> 
0

尝试

<ImageView 
     android:layout_width="0dp" 
     android:layout_weight="1" 
     android:layout_height="@dimen/social" 
     android:src="@drawable/facebook" /> 

对于每个ImageViews的。这应该使它们具有相等的总线宽布局宽度。我不确定这是否会延长图像,如果是这样,您可能需要设置缩放类型。