开发者

Android - how to position this custom balloon view with RelativeLayout

开发者 https://www.devze.com 2023-04-09 01:21 出处:网络
Im stuck in getting this to work. Look at the picture below, i want the bubble to be placed under the image.

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

.

Android - how to position this custom balloon view with RelativeLayout

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="htt开发者_JAVA百科p://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>


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.


Check out how the Quick Actions were implemented here http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/. The functionality is similar to what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消