Reputation: 4408
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
Upvotes: 0
Views: 859
Reputation: 34301
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>
Upvotes: 0
Reputation: 22493
use
android:layout_weight="1" for parent
and android:layout_weight="0.5" for childs
Upvotes: 1
Reputation: 37729
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"
Upvotes: 0