java - 安卓应用布局

标签 java android layout

我正在为 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/

相关文章:

Java FlowLayout 确实把我的图片画得很小

java - 如何处理缓存未命中 : NotFoundException, contains() 或 `if (null == result)` ?

java - Android Hello world 项目未运行

java - 将当前项目位置传递给内部类?

android - 在 ListView 中单击一行中的按钮更改行中按钮的背景

android - 如何在 MapView 下方添加 TextView?

java - 我需要一个有效的算法和/或代码来对系统的泊松分布进行建模

Java-docx4j-ImportXHTML : issue with NamespacePrefixMapper not found

java - SWT - 最后一列不会占用多余的水平空间

HTML5、CSS3 flexbox 无法正常工作