Skip to content Skip to sidebar Skip to footer

How To Place A Text Between Two Images In Android

I want to create layout where I have two images at left and at right and text in center. I have tried to do it with relative layout but unfortunetly it was unsuccessfully. Could an

Solution 1:

Have you tried something like?

<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="wrap_content"android:layout_height="wrap_content"><ImageViewandroid:id="@+id/img1"android:layout_width="50dip"android:layout_height="50dip"android:layout_alignParentLeft="true"android:src="@drawable/image1"/><ImageViewandroid:id="@+id/img2"android:layout_width="50dip"android:layout_height="50dip"android:layout_alignParentRight="true"android:src="@drawable/image2"/><TextViewandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_toRightOf="@id/img1"android:layout_toLeftOf="@id/img2"android:layout_alignTop="@id/img1"android:text="I'm between!"/></RelativeLayout>

If you don't need more things on your view, you could want to use LinearLayout instead, since it's more easier to implement. In that case, you just have to play with the layout_weight attribute.

alt text

Post a Comment for "How To Place A Text Between Two Images In Android"