java - Android布局按布局

标签 java android android-studio

我怎样才能实现下一个又一个布局位置(有高度)?

enter image description here

当前代码:

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

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"></ListView>
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAlignment="center"
            android:text="Новая заметка"/>
    </RelativeLayout>
</RelativeLayout>

最佳答案

当您使用此代码添加“layout_above”属性时,您可以实现相同的布局。

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

<RelativeLayout
    android:layout_above="@+id/relativeBottom"
    android:layout_width="match_parent"
    android:layout_alignParentTop="true"
    android:layout_height="match_parent">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"></ListView>
</RelativeLayout>

<RelativeLayout
    android:id="@+id/relativeBottom"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true">

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAlignment="center"
        android:text="Новая заметка"/>
    </RelativeLayout>
</RelativeLayout>

关于java - Android布局按布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29448679/

相关文章:

java - 上传到imgur java

java - 将 CURL 转换为 Java 代码

flutter - 第一个项目中任务 ':app:processDebugManifest'的配置出现问题

java - 在屏幕上绘制纬度和经度

android - Android Studio 中的项目不再起作用

java - 从 firebase android 中删除自动 key 节点

java - Gradle + AspectJ找不到参数 “'的方法Aspectj()Aspectj'无法应用于 '(?, java.lang.String, ?, ?)'”

java - 将 ArrayList 中的元素添加到一起

android - 字节数组到图像的转换

android - 如何从 whatsapp fileprovider 获取 txt 文件