android - 如何在 Android 中创建此布局

标签 android android-layout xamarin.android

我正在玩弄 Mono Droid 并尝试实现以下布局

enter image description here

我会使用什么类型的布局? Android 中是否有任何类似 anchor 和对接(如 WinForms)的东西,以便它可以在某种程度上独立?

这仅适用于平板电脑,更适合我的实验。左侧面板内的按钮将重复。

谢谢。

最佳答案

根布局将是这样的:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:baselineAligned="false"
    android:orientation="horizontal"
    android:padding="5dp" >

    <RelativeLayout
        android:id="@+id/leftContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.8" >
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/rightContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1" >

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

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:text="btn1" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:text="btn2" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:text="btn3" />
        </RelativeLayout>
    </RelativeLayout>

</LinearLayout>

在左右布局的顶部添加动态项目作为 ListView。

关于android - 如何在 Android 中创建此布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13046195/

相关文章:

android - 流式实时音频

java - 应用程序未通过点击小部件启动

Android,findViewById 返回 null

java - 一种布局中图像的最大尺寸是多少?

android - Google Speech API示例,无法解析R

android - 从当前光标位置的 EditText 中获取单词

java - Gradle 同步失败 : A problem occurred evaluating settings

android - 将目标 sdk 从 22 更新为 26 后出现 Resource Not Found 异常

即使应用了提供的解决方案,图像在具有 XAML 表单的 Android 项目中不可见 - Xamarin

android - 带有 JSON.NET 的包非常大