Android浮动按钮在视图上

The*_*oot 13 android android-layout android-view

我试图在我的视图上有一个浮动按钮,我用Google搜索并发现这个链接很好地总结了它.

http://www.jondev.net/articles/Floating_Views_in_Android_(Buttons)

虽然这对于一个按钮来说是正确的,但是如果我想在"左上角"有两个浮动按钮而在"右下角"有另一个按钮.

我想到了一个相对布局,它有两个按钮,布局重力不同.这会有用吗 我试了一下,然后失败了.有没有其他人试图这样做?有没有办法做到这一点,如果是这样,请告诉我.

Tho*_*mmy 22

你可以通过以下方式实现RelativeLayout:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </ListView>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="15dp"
        android:layout_marginRight="15dp"
        android:text="Button" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

请注意,最后添加的Widget位于顶部.