【问题标题】:Android - how to position this custom balloon view with RelativeLayoutAndroid - 如何用RelativeLayout定位这个自定义气球视图
【发布时间】:2011-09-27 20:50:47
【问题描述】:

我坚持让这个工作。

看下面的图片,我想把气泡放在图片下面。
当然希望能够将视图放置在我喜欢的任何地方。

我认为问题出在父视图中,因此我将父 xml 添加到 .
也许我需要将 RelativeLayout 更改为其他内容,
我尝试了很多东西,但没有任何效果

.

这是我的气泡 xml

<?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 >   

这是我将气泡插入的父级 .

<?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>

【问题讨论】:

    标签: android android-relativelayout custom-view


    【解决方案1】:

    您将需要创建一个包含 ImageView 和其中的气泡的 RelativeLayout。使用 position below 属性将气泡定位在 ImageView 下方。从那里您可以将RelativeLayout 移动到任何地方,气泡将保留在图像下方。

    【讨论】:

    • 太棒了,当然你的权利这是可行的,RelativeLayout 只是一个视图,所以我可以移动它
    【解决方案2】:

    在http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/ 处查看快速操作是如何实现的。功能与您想要的相似。

    【讨论】:

    • 我在搜索过程中看到了该帖子。我想我可以先试试这个,因为那个更复杂,代码也更多
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-02
    • 2017-09-05
    相关资源
    最近更新 更多