Android-UI布局2

本文对比了Android应用开发中使用的两种布局方式——绝对布局与标签布局,详细解释了它们的工作原理、特点及运行结果。通过实例展示了如何在布局中精确控制元素位置,以及标签布局如何以表格形式组织视图元素。

绝对布局

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/AbsoluteLayout01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <TextView
        android:id="@+id/txtIntro"
        android:text="使用绝对布局"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="20dip"
        android:layout_y="20dip">
    </TextView>
</AbsoluteLayout>

运行结果:


绝对布局可以让子元素指定准确的x和y坐标值,并显示在屏幕上。其中坐标(0,0)为左上角,当向下或向右移动时坐标值将会变大。

绝对布局无页边框,允许元素之间互相重叠。


标签布局

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/AbsoluteLayout01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TableRow>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="7"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="8"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="9"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="/"/>
    </TableRow>
    <TableRow>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="4"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="5"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="6"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="*"/>
    </TableRow>
    <TableRow>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="1"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="2"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="3"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="."/>
    </TableRow>
    <TableRow>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="0"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="="/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="-"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="+"/>
    </TableRow>
</TableLayout>

运行结果:

标签布局是一个ViewGroup以标签的方式显示它的子视图元素,就像Firefox中的一个窗口中显示多个网页一样。

【资源简介】本资源精心整理了 Claude Code 的三套完整源码方案,覆盖从底层破解研究到直接上手运行的全场景需求。无论你是想深入探究 AI 编程工具的技术原理,还是只想快速搭建环境体验效果,这里都有适合你的解决方案。【包含内容】第一套方案来自 Janlaywss 的原始破解版本,完整保留了 npm 安装包、自动化还原脚本以及通过 source map 反编译后的真实源码,附带详细的构建流程文档,非常适合对逆向工程和安全研究感兴趣的技术研究者深入了解整个破解还原过程。第二套方案学术研究版本,提供了纯净的 src 源码快照,配合详尽的架构分析文档,系统梳理了 Claude Code 的模块设计、通信机制和核心逻辑,是前端开发者学习大型 AI 应用架构设计的优质教材。第三套方案是开箱即用的可运行版本,已提前配置好所有 shim 补丁、依赖环境和 tsconfig 编译选项,真正实现下载后执行 bun install && bun run dev 即可启动,省去繁琐的环境折腾,强烈推荐想快速体验的同学优先选择这套方案。【适用人群】AI 工具研究者、前端架构学习者、逆向工程爱好者,以及所有对 Claude Code 实现原理感兴趣、希望快速搭建本地测试环境的开发者。【快速开始】推荐新手直接解压 03-claude-code-runnable 目录,安装 Bun 运行环境后执行两条命令即可看到效果,全程不超过 5 分钟。【技术栈】TypeScript / Bun / Node.js / Source Map 反编译
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值