gpt4 book ai didi

android - 动态 View 高

转载 作者:行者123 更新时间:2023-11-30 04:49:05 24 4
gpt4 key购买 nike

我是 Android 平台的新手。我正在尝试制作一个将屏幕分为三个部分的 View 。第一段应该是 200dip 高,第三段应该是 50dip 高,中间部分应该占据中间的剩余位置。有什么办法可以实现吗?我尝试了一些方法,但要么不起作用,要么应用程序崩溃了。感谢帮助帕特里克

最佳答案

当然。使用如下所示的 RelativeLayout。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Defining the top view -->
<View android:layout_alignParentTop="true"
android:layout_height="200dip"
android:layout_width="fill_parent"
android:id="@+id/top_view"
android:background="#FFFF00"/>
<!-- Defining the bottom view -->
<View android:layout_alignParentBottom="true"
android:layout_height="50dip"
android:layout_width="fill_parent"
android:id="@+id/bottom_view"
android:background="#00FFFF"/>
<!-- Defining the view in between those views -->
<View android:layout_above="@id/bottom_view"
android:layout_below="@id/top_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF0000"/>
</RelativeLayout>

在代码中为您提供了注释。

关于android - 动态 View 高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4031585/

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