0

I want to place my images within a Liner layout / Relative Layout

I want to keep two images in a row . How do i define the width of these images so that , both together fills the parent horizontally.

I can use layout_margin for the required gap between the images. But i am not able to define the width so that it fills the parent.

Do i have to do trial with different dip values

png
  • 4,368
  • 7
  • 69
  • 118
  • use android:layout_weight , see this post : http://stackoverflow.com/questions/3995825/what-is-androidlayout-weight-meaning – Houcine Oct 20 '11 at 12:57

3 Answers3

1

use

android:layout_weight="1"  for parent
and android:layout_weight="0.5" for childs 
RajaReddy PolamReddy
  • 22,428
  • 19
  • 115
  • 166
0

set LinearLayout's orientation to Horizontal

Put two ImageViews with property

android:layout_width = "fill_parent"
android:layout_height = "wrap_content"
android:layout_weight = "1"
Adil Soomro
  • 37,609
  • 9
  • 103
  • 153
  • Actually this question was my partial requirement. The actual question is http://stackoverflow.com/questions/7834737/android-row-spanning-for-images/7834816#7834816 – png Oct 20 '11 at 12:34
  • Since i didnt get answer i was trying to attack problem by problem. It would be great if you have any solutions for my problem. I trie by assigning weight but its not working – png Oct 20 '11 at 12:36
0

try this way in your xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:weightSum="2">
    <ImageView android:layout_height="wrap_content" android:id="@+id/imageView1"
        android:src="@drawable/icon" android:layout_width="0dp"
        android:layout_weight="1" android:scaleType="fitXY"></ImageView>
    <ImageView android:layout_height="wrap_content" android:id="@+id/imageView1"
        android:src="@drawable/icon" android:layout_width="0dp" android:scaleType="fitXY"
        android:layout_weight="1"></ImageView>
</LinearLayout>
MKJParekh
  • 34,073
  • 11
  • 87
  • 98
  • thank you.can you please look in to http://stackoverflow.com/questions/7834737/android-row-spanning-for-images/7834816#7834816 and correct my xml . – png Oct 20 '11 at 12:38