gpt4 book ai didi

java - 安卓应用布局

转载 作者:行者123 更新时间:2023-11-29 22:10:42 24 4
gpt4 key购买 nike

我正在为 2.2 版本开发一个 android 应用。

我的应用必须有这样的结构:

[此处的微调器(固定高度)]

[ListView(不固定高度)]

[ ImageView(固定高度)]

我只能使用纵向。

我为此使用 linearLayout。我如何计算 listView 高度以在屏幕顶部显示微调器,在底部显示 ImageView ,而 listview 覆盖所有可用空间,但不将其他人推离视野。

让它动态适应很多屏幕分辨率会很酷。

谢谢

最佳答案

使用相对布局来完成您需要的。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />

<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:src="@drawable/icon" />

<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/spinner1"
android:layout_above="@+id/imageView1" />

</RelativeLayout>

通过执行此操作, ListView 将调整其大小,使其适合屏幕上的微调器和 ImageView

关于java - 安卓应用布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9709465/

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