【线性布局和相对布局的加深理解】:练习和见解(图书显示)

2024-05-12 22:38

本文主要是介绍【线性布局和相对布局的加深理解】:练习和见解(图书显示),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

关于线性布局注意内容:
布局中一般RelativeLayout都是在LinearLayout里面,
关于权重weight的加深理解是,weight只有在LinerLayout才能被使用,这是很重要的一点,
RelativeLayout中使用权重weight必须满足条件有:
1.RelativeLayout是在LinearLayout下面进行布局设计
2.LinearLayout必须指定布局方向也就是:android:orientation="vertical"
如果没有指定布局方向的话RelativeLayout使用weight权重也是会出现错误

接下来就是进行设计范围,和基础篇2相同,设计的是图书显示页面:
在这里插入图片描述代码实现如下:


```csharp
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="10dp"android:background="#8492a6"></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><LinearLayoutandroid:orientation="vertical"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:background="#f4f4"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="2"android:background="#7ba8b0"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="此处为图书封面"android:textSize="18sp" /></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="3dp"android:background="#bfd9d4"></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="书名"android:textSize="18sp"/></RelativeLayout></LinearLayout><RelativeLayoutandroid:layout_width="3dp"android:layout_height="match_parent"android:background="#7489ab"></RelativeLayout><LinearLayoutandroid:orientation="vertical"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="2"android:background="#bfd9d4"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="概述"android:textSize="18sp" /></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="5dp"android:background="#2e4d5c"></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="作者"android:textSize="18sp" /></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="5dp"android:background="#2e4d5c"></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="日期"android:textSize="18sp" /></RelativeLayout></LinearLayout></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="10dp"android:background="#8492a6"></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><LinearLayoutandroid:orientation="vertical"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:background="#f4f4"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="2"android:background="#7ba8b0"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="此处为图书封面"android:textSize="18sp" /></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="3dp"android:background="#bfd9d4"></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="书名"android:textSize="18sp"/></RelativeLayout></LinearLayout><RelativeLayoutandroid:layout_width="3dp"android:layout_height="match_parent"android:background="#7489ab"></RelativeLayout><LinearLayoutandroid:orientation="vertical"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="2"android:background="#bfd9d4"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="概述"android:textSize="18sp" /></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="5dp"android:background="#2e4d5c"></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="作者"android:textSize="18sp" /></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="5dp"android:background="#2e4d5c"></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="日期"android:textSize="18sp" /></RelativeLayout></LinearLayout></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="10dp"android:background="#8492a6"></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><LinearLayoutandroid:orientation="vertical"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:background="#f4f4"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="2"android:background="#7ba8b0"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="此处为图书封面"android:textSize="18sp" /></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="3dp"android:background="#bfd9d4"></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="书名"android:textSize="18sp"/></RelativeLayout></LinearLayout><RelativeLayoutandroid:layout_width="3dp"android:layout_height="match_parent"android:background="#7489ab"></RelativeLayout><LinearLayoutandroid:orientation="vertical"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="2"android:background="#bfd9d4"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="概述"android:textSize="18sp" /></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="5dp"android:background="#2e4d5c"></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="作者"android:textSize="18sp" /></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="5dp"android:background="#2e4d5c"></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:background="#bfd9d4"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="日期"android:textSize="18sp" /></RelativeLayout></LinearLayout></LinearLayout></LinearLayout>

这篇关于【线性布局和相对布局的加深理解】:练习和见解(图书显示)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/983940

相关文章

C++对象布局及多态实现探索之内存布局(整理的很多链接)

本文通过观察对象的内存布局,跟踪函数调用的汇编代码。分析了C++对象内存的布局情况,虚函数的执行方式,以及虚继承,等等 文章链接:http://dev.yesky.com/254/2191254.shtml      论C/C++函数间动态内存的传递 (2005-07-30)   当你涉及到C/C++的核心编程的时候,你会无止境地与内存管理打交道。 文章链接:http://dev.yesky

JAVA读取MongoDB中的二进制图片并显示在页面上

1:Jsp页面: <td><img src="${ctx}/mongoImg/show"></td> 2:xml配置: <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001

vue, 左右布局宽,可拖动改变

1:建立一个draggableMixin.js  混入的方式使用 2:代码如下draggableMixin.js  export default {data() {return {leftWidth: 330,isDragging: false,startX: 0,startWidth: 0,};},methods: {startDragging(e) {this.isDragging = tr

据阿谱尔APO Research调研显示,2023年全球髓内钉市场销售额约为4.7亿美元

根据阿谱尔 (APO Research)的统计及预测,2023年全球髓内钉市场销售额约为4.7亿美元,预计在2024-2030年预测期内将以超过3.82%的CAGR(年复合增长率)增长。 髓内钉市场是指涉及髓内钉制造、分销和销售的行业。髓内钉是一种用于整形外科手术的医疗器械,用于稳定长骨骨折,特别是股骨、胫骨和肱骨。髓内钉通常由不銹钢或钛等材料制成,并插入骨的髓管中,以在愈合过程中提供结构支

回调的简单理解

之前一直不太明白回调的用法,现在简单的理解下 就按这张slidingmenu来说,主界面为Activity界面,而旁边的菜单为fragment界面。1.现在通过主界面的slidingmenu按钮来点开旁边的菜单功能并且选中”区县“选项(到这里就可以理解为A类调用B类里面的c方法)。2.通过触发“区县”的选项使得主界面跳转到“区县”相关的新闻列表界面中(到这里就可以理解为B类调用A类中的d方法

Android多线程下载见解

通过for循环开启N个线程,这是多线程,但每次循环都new一个线程肯定很耗内存的。那可以改用线程池来。 就以我个人对多线程下载的理解是开启一个线程后: 1.通过HttpUrlConnection对象获取要下载文件的总长度 2.通过RandomAccessFile流对象在本地创建一个跟远程文件长度一样大小的空文件。 3.通过文件总长度/线程个数=得到每个线程大概要下载的量(线程块大小)。

vue+elementUI下拉框联动显示

<el-row><el-col :span="12"><el-form-item label="主账号:" prop="partyAccountId" :rules="[ { required: true, message: '主账号不能为空'}]"><el-select v-model="detailForm.partyAccountId" filterable placeholder="

如何理解redis是单线程的

写在文章开头 在面试时我们经常会问到这样一道题 你刚刚说redis是单线程的,那你能不能告诉我它是如何基于单个线程完成指令接收与连接接入的? 这时候我们经常会得到沉默,所以对于这道题,笔者会直接通过3.0.0源码分析的角度来剖析一下redis单线程的设计与实现。 Hi,我是 sharkChili ,是个不断在硬核技术上作死的 java coder ,是 CSDN的博客专家 ,也是开源

MySQL理解-下载-安装

MySQL理解: mysql:是一种关系型数据库管理系统。 下载: 进入官网MySQLhttps://www.mysql.com/  找到download 滑动到最下方:有一个开源社区版的链接地址: 然后就下载完成了 安装: 双击: 一直next 一直next这一步: 一直next到这里: 等待加载完成: 一直下一步到这里

PyTorch模型_trace实战:深入理解与应用

pytorch使用trace模型 1、使用trace生成torchscript模型2、使用trace的模型预测 1、使用trace生成torchscript模型 def save_trace(model, input, save_path):traced_script_model = torch.jit.trace(model, input)<