gpt4 book ai didi

android - 如何在 Android 的单个 View 上 float 多个 View

转载 作者:行者123 更新时间:2023-11-29 18:08:46 25 4
gpt4 key购买 nike

我正在尝试找出一种将多个 View float 在另一个 View 上的方法,可能是 ListViewGridLayout。几乎所有的问题都用 FrameLayout 来回答,不幸的是这不起作用,因为它是为了 float 单个 View 而设计的,因此排除了它的问题。我正在考虑使用 RelativeLayout,但我无法弄清楚如何让它与之一起工作。有没有人能想出办法做到这一点?任何建议将不胜感激!

最佳答案

RelativeLayout 中靠后的子项 float 在靠前的子项之上。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/big"
android:textSize="120dip"
android:textStyle="bold"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/small"/>

</RelativeLayout>

第二个 Button 浮在第一个 Button 之上,给你:

big under small

这是完整的示例项目:https://github.com/commonsguy/cw-omnibus/tree/master/Containers/RelativeOverlap .

关于android - 如何在 Android 的单个 View 上 float 多个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11944094/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com