Give Equal Space Between Imageviews
i am trying to add some social images in my app about me screen but i am facing a problem of giving equal spaces between imageviews. my images looks like this: but i want to make
Solution 1:
There you go, modify the code accordingly, learn about android:layout_weight
it is usefull in such situations:
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><ImageViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:src="@drawable/ic_launcher" /><ImageViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:src="@drawable/ic_launcher" /><ImageViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:src="@drawable/ic_launcher" /><ImageViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:src="@drawable/ic_launcher" /><ImageViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:src="@drawable/ic_launcher" /></LinearLayout>
Solution 2:
set layout_margin property of imageview to give space between thos image view.
Solution 3:
Use <Space/>
element in your Linearlayout between the imageviews to add equal space. You can assign the width using the weight property of LinearLayouts to get equally spaced icons in all different form factors.
Example:
<LinearLayoutandroid: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 --><ImageViewandroid:layout_width="@dimen/social"android:layout_height="@dimen/social"android:src="@drawable/facebook" /><Spaceandroid:layout_width="15dp"android:layout_height="match_parent"/><!-- Twitter --><ImageViewandroid:layout_width="@dimen/social"android:layout_height="@dimen/social"android:src="@drawable/twitter" /></LinearLayout>
Solution 4:
Try
<ImageView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="@dimen/social"
android:src="@drawable/facebook" />
For each of the ImageViews. This should give them equal width of the total linearlayout width. I'm not sure if this will stretch your images or not, if it does you might need to set the scale type.
Post a Comment for "Give Equal Space Between Imageviews"