Reputation: 141
I am drawing a Linear layout in Android to display 2 images with half image in left side and half image.
I draw like this :
but I want to draw like below, can you please help me to draw the image like below.
My layout file is here:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.5" >
<ImageView
android:id="@+id/sideLeft"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:layout_marginBottom="10dp"
android:background="@drawable/user"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/sideRight"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_weight="1.5"
android:layout_marginBottom="10dp"
android:background="@drawable/user"
android:scaleType="centerCrop" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
That will look like a 1 image.
Thanks In Advance!
Upvotes: 0
Views: 1131
Reputation: 2417
You need to work on java for such output,
Set both image fit center, And from Java set first imageview's right padding as -width/2, and second imageview's left padding as -width/2. Here width is imageview's width.
It may help you.
Upvotes: 1
Reputation: 27515
Try this
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="center"
android:layout_weight="1.5" >
<ImageView
android:id="@+id/sideLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="@drawable/user"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/sideRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="1dp"
android:layout_marginBottom="10dp"
android:background="@drawable/user"
android:scaleType="centerCrop" />
</LinearLayout>
Upvotes: 0