Search code examples
androidandroid-relativelayoutcustom-view

Android - how to position this custom balloon view with RelativeLayout


Im stuck in getting this to work.

Look at the picture below, i want the bubble to be placed under the image.
And of course would like to be able to place the view wherever i like.

I think the problem is in the parent view so i add parent xml to .
Maybe i need to change RelativeLayout to something else,
I have tried many things but nothing works

.

enter image description here

Here is my xml for the bubble

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout  android:id="@+id/frameLayout_balloon_gallery_activity_send"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android">

    <ImageView android:id="@+id/imv_balloon_gallery_activity_send"
        android:src="@drawable/balloon_gallery"
        android:scaleType="fitCenter"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"/>

</FrameLayout >   

here is the parent that i insert the bubble into .

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/relativelayout_main_activity_back"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical">


    <Gallery xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/gallery_activity_back"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:spacing="2dip"
        android:gravity="top"
        android:paddingTop="20dip"
    />
    <RelativeLayout
        android:id="@+id/relativeLayoutinner_activity_back"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <EditText
            android:id="@+id/etx_addtext_activity_back"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:singleLine="false"
            android:text="@string/string_enter_text_here"
        />

    </RelativeLayout>

</RelativeLayout>

Solution

  • You will want to create a RelativeLayout that contains both the ImageView and the bubble inside it. Position the bubble below the ImageView using the position below attribute. From there you can move the RelativeLayout around wherever and the bubble will remain under the image.