gpt4 book ai didi

android - android 中的边框布局?

转载 作者:太空宇宙 更新时间:2023-11-03 12:24:16 26 4
gpt4 key购买 nike

有没有办法在 android 中实现一个有效可重复使用的边框布局?一种行为类似于 swing 的 BorderLayout:最大化中间部分并将其余部分缩小到最小尺寸?

最佳答案

尝试一下,您将获得与 Swings BorderLayout 相同的行为(结果如图所示):

BorderLayout Demo

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

<TextView
android:id="@+id/north"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@android:color/holo_orange_light"
android:gravity="center_horizontal"
android:text="North"
android:textAppearance="@android:style/TextAppearance.Large" />

<TextView
android:id="@+id/south"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:color/holo_blue_light"
android:gravity="center_horizontal"
android:text="South"
android:textAppearance="@android:style/TextAppearance.Large" />

<TextView
android:id="@+id/west"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_above="@id/south"
android:layout_alignParentLeft="true"
android:layout_below="@id/north"
android:background="@android:color/holo_red_light"
android:gravity="center_vertical"
android:text="West"
android:textAppearance="@android:style/TextAppearance.Large" />

<TextView
android:id="@+id/east"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_above="@id/south"
android:layout_alignParentRight="true"
android:layout_below="@id/north"
android:background="@android:color/holo_purple"
android:gravity="center_vertical"
android:text="East"
android:textAppearance="@android:style/TextAppearance.Large" />

<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/south"
android:layout_below="@id/north"
android:layout_toLeftOf="@id/east"
android:layout_toRightOf="@id/west"
android:background="@android:color/holo_green_light"
android:gravity="center"
android:text="Center"
android:textAppearance="@android:style/TextAppearance.Large" />

关于android - android 中的边框布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6473132/

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