Android复杂布局线性和相对

2024-05-21

I have to implement a layout like shown in the diagram, and I do not know the best combination to achieve the required design. I'm designing for the 7" tablet and want the design to stretch well on the 10" enter image description here

我假设像 1、2、3、4、5 这样的布局是 LinearLayout,对吗?

*活动安排是怎样的?我尝试了RelativeLayout,但我无法在布局1、2、3之间分配宽度(使用android:layout_weight)

*我在整个活动中尝试了水平线性布局,但无法将页眉和页脚布局正确添加到主水平线性布局

我阅读了文档和教程,但找不到这个复杂设计的线索,请帮助。

另外,嵌套布局对性能有何影响?

Thanks,


你可以尝试这样的事情,正如其他人所说,在这个级别你不会有性能问题

<?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:orientation="vertical"
android:weightSum="1" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.2"
    android:background="@android:color/holo_orange_light"
    android:orientation="horizontal"
    android:weightSum="1" >

    <View
        android:id="@+id/view1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_weight="0.2"
        android:background="@android:color/black" />

    <View
        android:id="@+id/view2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_weight="0.8"
        android:background="@android:color/black" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.6"
    android:background="@android:color/holo_blue_light"
    android:orientation="horizontal"
    android:weightSum="1" >

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:layout_weight="0.2"
        android:background="@android:color/holo_purple"
        android:orientation="vertical"
        android:weightSum="1" >

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.2"
            android:background="@android:color/black" />

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.3"
            android:background="@android:color/black" />

        <View
            android:id="@+id/view2"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.5"
            android:background="@android:color/black" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:layout_weight="0.4"
        android:background="@android:color/holo_red_dark"
        android:orientation="vertical"
        android:weightSum="1" >

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.33"
            android:background="@android:color/black" />

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.33"
            android:background="@android:color/black" />

        <View
            android:id="@+id/view2"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.33"
            android:background="@android:color/black" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:layout_weight="0.4"
        android:background="@android:color/darker_gray"
        android:orientation="vertical"
        android:weightSum="1" >

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.5"
            android:background="@android:color/black" />

        <View
            android:id="@+id/view2"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.5"
            android:background="@android:color/black" />
    </LinearLayout>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.2"
    android:background="@android:color/holo_green_light"
    android:orientation="horizontal"
    android:weightSum="1" >

    <View
        android:id="@+id/view1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_weight="0.2"
        android:background="@android:color/black" />

    <View
        android:id="@+id/view1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_weight="0.3"
        android:background="@android:color/black" />

    <View
        android:id="@+id/view2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_weight="0.5"
        android:background="@android:color/black" />
</LinearLayout>

</LinearLayout>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android复杂布局线性和相对 的相关文章

随机推荐

  • 找不到此可执行文件的有效配置文件...(再次)

    我知道这个问题已经被问过并回答过多次 但我正在抓狂 因为所提出的解决方案似乎都不起作用 尽管有一个有效的配置文件 但据我所知 它与捆绑包标识符匹配 但我收到了上述错误 我已按照本网站上各种建议解决方案中的步骤进行操作 包括删除所有现有证书并
  • Rails 3.2 子域和设计

    我有一个应用程序 用户可以登录到他们的公司子域 我用的是设计 此代码将用户从根域重定向到子域 def after sign in path for resource or scope scope Devise Mapping find sc
  • Weka J48 分类器:无法处理数字类?

    我现在尝试使用 Weka 在我的训练数据上构建 J48 C4 5 分类器模型 首先我这样做 这似乎很顺利 java Xmx10G cp weka weka jar weka core converters TextDirectoryLoad
  • 将 PropertyPlaceholderConfigurer 中的所有属性注入到 bean 中

    我有一个PropertyPlaceholderConfigurer加载多个属性文件 我想通过配置 XML 将合并的属性映射注入到 Spring Bean 中 我可以这样做以及如何做 您只需创建一个属性 bean 并将其用于您的Propert
  • 如果你使用belongs_to而没有相应的has_one,会发生什么?

    我有一个核心模型Item 以及一个从自定义源 例如 RSS feed 填充它的脚本 在 feed 中 每个项目都用一个标识guid 在我的系统中 项目只有一个自动生成的id首要的关键 我想要 比方说 ItemFeedInfo那个地图guid
  • 在服务器上部署 .war 文件(Liferay+Tomcat Bundle)

    我已经准备好我的新 Liferay 网站并尝试在真实环境中测试它 我刚刚在我的服务器上成功安装了 Tomcat Liferay 捆绑包 并根据一些论坛和评论的说明将 war 文件复制到 tomcat 旁边的部署目录中 但访问该 URL 后
  • 使用 Riverpod 处理身份验证

    我正在尝试获取 Riverpod 但遇到了一些问题 我创建了一个用于登录用户的表单 并且尝试在用户登录时更改主视图 我的问题是 当我设置更改状态并导航回应用程序根目录时 新状态似乎不可用 但是 如果我保存文件或热重新加载应用程序 则新状态可
  • 根据用户输入使用 Jquery 显示/隐藏字段

    li class numeric optional li
  • 我该如何找出 npm 包的最新稳定版本?

    如何找到 npm 包的最新稳定版本 除了去http search npmjs org http search npmjs org并寻找它 我通常需要该版本才能将其放入我的package json Use npm view package n
  • iTunes Connect 中缺少应用内购买部分

    我有一个应用程序处于准备提交状态 我还有该应用程序的应用程序内购买项目 上周我将它们链接到我的应用程序并提交以供审核 周末 开发商拒绝了它 现在我想重新提交修复后的版本 但 IAP 部分完全丢失 我怎样才能让它再次可见 我遇到过同样的问题
  • Android XML:百分比高度和宽度来创建独特的布局

    I ve heard so much about weight etc However most of the tutorials refer always to width percentage I wish to do the foll
  • 是否可以使用打字稿映射类型来创建接口的非函数属性类型?

    所以我正在研究 Typescript 的映射类型 是否可以创建一个接口来包装另一种类型 从而从原始类型中删除函数 例如 interface Person name string age number speak void type Data
  • ANTLR 获取并拆分词法分析器内容

    首先 对我的英语感到抱歉 我还在学习 我为我的框架编写 Python 模块 用于解析 CSS 文件 我尝试了 regex ply python 词法分析器和解析器 但我发现自己在 ANTLR 中 第一次尝试 我需要解析 CSS 文件中的注释
  • 如何在 Java 中创建一个带有连字符的值的静态枚举?

    如何创建如下所示的静态枚举 static enum Test employee id employeeCode 截至目前 我遇到了错误 这对于 Java 来说是不可能的 因为每个项目都必须是有效的标识符 并且有效的 Java 标识符可能不包
  • 使用“默认”环境变量启动新的子进程

    我正在编写一个构建脚本来解析依赖的共享库 及其共享库等 这些共享库在正常情况下是不存在的PATH环境变量 为了使构建过程正常工作 让编译器找到这些库 PATH已更改为包含这些库的目录 构建过程是这样的 加载器脚本 更改 PATH gt 基于
  • C++ 到 C# 事件处理

    所以我有我的C WinForm 应用程序 我从中调用我的C CLI MFC dll图书馆 但也有一些events在我的 C 库上 甚至此事件也发生在该库的本机 非 CLI 部分 我需要从我的 C 应用程序调用一些代码 并获取一些有关此事件的
  • 返回表示每组内最大值的索引的一系列数字位置

    考虑一下这个系列 np random seed 3 1415 s pd Series np random rand 100 pd MultiIndex from product list ABDCE list abcde One Two T
  • 快速像素绘图库

    我的应用程序以每像素的方式生成 动画 因此我需要有效地绘制它们 我尝试过不同的策略 库 但结果并不令人满意 尤其是在更高分辨率的情况下 这是我尝试过的 SDL 好的 但是慢 OpenGL 像素操作效率低下 xlib 更好 但仍然太慢 svg
  • 函数速度测试的奇怪结果

    我编写了一个使用递归来查找最大公因数 分母 的函数 gt gcd function a b if length a length b gt 1 warning Only scalars allowed using first element
  • Android复杂布局线性和相对

    I have to implement a layout like shown in the diagram and I do not know the best combination to achieve the required de