0

In my application, I want the text to appear above the image view with padding 2 dp. But when I run the program the textview overlays the image. How can I make the image appear 2dp below textview using <merge> </merge>?

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_gravity="center_vertical|center_horizontal">

    <ImageView

        android:id="@+id/item_image"
        android:layout_width="253dp"
        android:layout_height="240dp"
        android:layout_gravity="center"
        android:scaleType="fitXY"
        android:src="@drawable/one_louisrossi" />

    <TextView

        android:id="@+id/title"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/fourty_eight"
        android:layout_weight="1.30"
        android:gravity="center_horizontal"
        android:text="xxxxxx"
        android:textColor="@color/white"
        android:textSize="@dimen/eighteen"
        android:textStyle="bold" />

</merge>
Adi Inbar
  • 12,097
  • 13
  • 56
  • 69
Dimitri
  • 1,924
  • 9
  • 43
  • 65

4 Answers4

0

This is dependant on the parent container view from which you are including the merge.

Since you actually have an intended layout, I suggest you actually switch from a merge tag to a linear layout or relativelayout.

Pork 'n' Bunny
  • 6,740
  • 5
  • 25
  • 32
0

To make the image appear below instead of appearing above it i would recommend a linear layout.

Necro
  • 333
  • 5
  • 18
0

If you want your TextView on ImageView then use FrameLayout or RelativeLayout.

The difference between FrameLayout and RelativeLayout is the first has different layer for view, so child views don't interact with each other

pavko_a
  • 507
  • 4
  • 16
0

<ImageView

    android:id="@+id/item_image"
    android:layout_width="253dp"
    android:layout_height="240dp"
    android:layout_gravity="center"
    android:scaleType="fitXY"
    android:src="@drawable/one_louisrossi"
    android:layout_below="@+id/title"
/>

<TextView

    android:id="@+id/title"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/fourty_eight"
    android:layout_weight="1.30"
    android:gravity="center_horizontal"
    android:text="xxxxxx"
    android:textColor="@color/white"
    android:textSize="@dimen/eighteen"
    android:textStyle="bold"
/>

Adi Inbar
  • 12,097
  • 13
  • 56
  • 69
nilesh patel
  • 834
  • 1
  • 5
  • 10