Android百分比布局支持库(android-percent-support)

Docker+vLLM内网离线部署Qwen3 流程 本文介绍了在CentOS 7系统下进行VLLM容器化部署Qwen3-32B大模型的内网离线方案。首先需准备Nvidia显卡驱动、CUDA 12.4和Docker环境。通过联网机器拉取vllm/vllm-openai镜像并导入内网服务器,同时从魔塔社区下载模型文件。部署时使用docker run命令启动容器,配置了GPU资源、内存共享、端口映射等参数,特别指定了模型路径、并行计算、内存利用率等关键参数。该方案实现了大模型在内网环境的安全高效部署,适用于需要离线运行的AI推理场景。 阅读详情

Android中提供了五种布局,其中用的最多的就是:LinearLayout, RelativeLayout 和 FrameLayout这三种布局,在对某一界面进行布局时最先想到也是通过这三种来布局的,不过当某一界面过于复杂时,往往会有多层嵌套,可能嵌套层数过深超过5层,比如,当我们有一个需求是这样的:界面中的一个按钮的长度需要是屏幕宽度的一半,而且需要在任何屏幕下都是屏幕宽度的一半,这个需求我们往往想到的就是用LinearLayout的weightSum属性和child的layout_weight属性结合来用来达到效果,你可能这样实现:
单独给这个Button包一层LinearLayout来设置weightSum和layout_weight:

<RelativeLayout   xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_horizontal"
        android:weightSum="1">
    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.5"
        android:text="Button"/>
    </LinearLayout>
</RelativeLayout>

最后也达到了效果:
这里写图片描述

不过这样未免太浪费了吧,如果我的视图更复杂一些,比如要实现下面这样的布局,都是需要按照屏幕的宽高来给控件设置宽高比例,那么如果真要实现那么你的layout文件一定非常大。
竖屏:
这里写图片描述
横屏:
这里写图片描述

可以看到,这的确是适配屏幕的,是按照屏幕的宽高来对控件进行不同比例的设置。

要完成上面这样的布局,如果采用通常方法来布局那么将非常复杂,庆幸的是Google推出了一种新的布局库,叫百分比布局库,可以在sdk目录下就可以找到对应的jar包,然后把它添加到项目中即可使用,即:
这里写图片描述

所以,我们采用百分比布局来实现上面这种布局。

百分比布局库android-percent-support

百分比布局库中提供了两种布局可以设置百分比:PercentRelativeLayout、PercentFrameLayout,为什么没有LinearLayout呢?因为LinearLayout可以根据weightSum和layout_weight这两个属性来对child进行很方便的布局适配。

这两个百分比布局都有以下九个布局属性,值都是用百分比来表示宽度、高度、margin值,使用时候需要父布局为百分比布局,child控件才可以使用这九个布局属性:

  • app:layout_heightPercent
  • app:layout_widthPercent
  • app:layout_marginPercent
  • app:layout_marginTopPercent
  • app:layout_marginBottomPercent
  • app:layout_marginLeftPercent
  • app:layout_marginRightPercent
  • app:layout_marginStartPercent
  • app:layout_marginEndPercent

使用如下:

<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:id="@+id/button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="width=50%"
        app:layout_widthPercent="50%" />
</android.support.percent.PercentRelativeLayout>

上面这样就设置了Button的宽度是父布局宽度的一半,所以在不同屏幕下也永远是父布局宽度的一般,这样很方便的实现了而不需要用LinearLayout设置weightSum和layout_weight来控制。

用百分比布局实现上图布局

其实PercentRelativeLayout 和PercentFrameLayout就是多了九个布局属性的RelativeLayout 和FrameLayout,用法完全和这两个布局一样,不过只有父布局是百分比布局(PercentRelativeLayout和PercentFrameLayout )的时候,child才能使用百分比布局属性进行布局,否则无效,如:

<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <Button
        android:id="@+id/button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="width=50%"
        app:layout_widthPercent="50%" />
    </LinearLayout>
</android.support.percent.PercentRelativeLayout>

这样设置Button的宽度并不会是父布局宽度的一半,因为child用百分比只对父布局是百分比布局才有效。

好了,现在就直接贴下上面这幅图的布局xml:

<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:id="@+id/button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="width=50%"
        app:layout_widthPercent="50%" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_below="@id/button"
        android:background="#E91E63"
        android:text="height=20%,width=50%"
        app:layout_heightPercent="20%"
        app:layout_marginLeftPercent="50%"
        app:layout_widthPercent="50%" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_below="@id/button"
        android:background="#9C27B0"
        android:text="height=20%,width=50%"
        app:layout_heightPercent="20%"
        app:layout_widthPercent="50%" />

    <android.support.percent.PercentRelativeLayout
        android:id="@+id/percent1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/textView2">

        <TextView
            android:id="@+id/textView3"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:background="#03A9F4"
            android:text="height=20%,width=25%"
            app:layout_heightPercent="20%"
            app:layout_widthPercent="25%" />

        <TextView
            android:id="@+id/textView4"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_toRightOf="@id/textView3"
            android:background="#CDDC39"
            android:text="height=20%,width=50%"
            app:layout_heightPercent="20%"
            app:layout_widthPercent="50%" />

        <TextView
            android:id="@+id/textView5"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_toRightOf="@id/textView4"
            android:background="#FF5722"
            android:text="height=20%,width=25%"
            app:layout_heightPercent="20%"
            app:layout_widthPercent="25%" />
    </android.support.percent.PercentRelativeLayout>

    <android.support.percent.PercentRelativeLayout
        android:id="@+id/percent2"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_below="@id/percent1"
        android:background="#FFCCBC"
        android:gravity="center_horizontal"
        app:layout_widthPercent="50%">

        <TextView
            android:id="@+id/textView6"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:background="#03A9F4"
            android:text="height=20%,width=25%"
            app:layout_heightPercent="20%"
            app:layout_marginTopPercent="10%"
            app:layout_widthPercent="50%" />

        <TextView
            android:id="@+id/textView7"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_below="@id/textView6"
            android:background="#CDDC39"
            android:text="height=20%,width=50%"
            app:layout_heightPercent="20%"
            app:layout_marginTopPercent="10%"
            app:layout_widthPercent="50%" />
    </android.support.percent.PercentRelativeLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/percent1"
        android:layout_toRightOf="@id/percent2"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="10">

            <Button
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2.5"
                android:text="B" />

            <Button
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2.5"
                android:text="B" />

            <Button
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="5"
                android:text="Button" />
        </LinearLayout>


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center_horizontal"
            android:weightSum="1">

            <Button
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.5"
                android:text="Button" />
        </LinearLayout>
    </LinearLayout>

</android.support.percent.PercentRelativeLayout>
学Simulink——基于Simulink的AUTOSAR架构下电机控制软件组件建模 本文详细介绍了在Simulink中基于AUTOSAR架构开发电机控制软件组件(SWC)的全流程。主要内容包括:首先阐述了AUTOSAR架构对汽车电子系统开发的价值,包括提高软件复用率、降低集成成本和改善验证环境。然后重点讲解了在Simulink中构建电机控制SWC的具体步骤:从创建AUTOSAR组件模型、定义数据端口和服务端口,到搭建FOC控制算法、配置运行实体,最后生成AUTOSAR描述文件和验证RTE接口。文章还提供了与基础软件(BSW)的集成方案、工程实践要点和常见问题解决方案,并以大众MEB平台等实 阅读详情

相关推荐

实战演练 | ABAQUS显式动力学分析在金属切削仿真中的应用

本文详细介绍了如何利用ABAQUS显式动力学分析进行金属切削过程的二维仿真。通过从零开始的完整流程,包括几何建模、材料本构与失效定义、网格划分、接触设置、边界条件施加,到结果后处理与切削力提取,为工程师和研究人员提供了实用的仿真方法,以优化刀具设计和加工工艺。

purple的博客 940

Android百分比布局支持库——com.android.support:percent

使用android-percent-support-lib-sample项目的价值: 提供PercentRelativeLayout、PercentFrameLayout给大家使用,对以下属性支持使用百分比方式 layout_widthPercent layout_heightPercent  layout_marginPercent layout_marginLeftPercent

梦工厂 3671

用Cursor+Node.js零代码搭建健康数据仪表盘:从数据录入到可视化全流程

本文详细介绍了如何利用Cursor AI编程助手和Node.js,无需手动编写代码,即可构建个人健康数据仪表盘的全流程。通过自然语言指令,实现从数据录入、存储到动态图表可视化的完整系统,展示了AI驱动开发在降低技术门槛、提升开发效率方面的强大能力。

gitlab7runner的博客 704

PercentRelativeLayout的使用和详解

看到这个名字就知道和RelativeLayout有关,对的,他是RelativeLayout的一个直接子类,他是Android5.0之后才出现的所以作为支持库出现,因此在使用它之前要在buile.gradle中先引入,接下来就一点点介绍这个东东。1、添加依赖 compile 'com.android.support:percent:25.0.0'2、先说说它的作用我门都知道LinearLayo

hello_1s的博客 7233

DCDC系列(一): COT DCDC基本原理

电流环DCDC属于双环控制模式,根据电流检测的位置,分为峰值电流环控制模式、谷值电流环控制模式和平均电流环控制模式,主要由输出电压反馈环和电流环两个环路来实现控制,其瞬态响应比电压环更好,且有自动限流的功能,但仍需要斜坡补偿网络,且对噪声敏感。Stage3: 在下管NMOS打开阶段,由于后级负载此时间段内消耗的电量较少,所以VFB还未低至Vref,所以此阶段中,上管PMOS和下管NMOS均处于关断状态,此时的电感电流为0mA,此阶段测的VSW上的电压就是Cout上的电压VREG;

weixin_40073649的博客 3979

UDS服务应该支持哪些否定响应码

UDS服务应该支持哪些否定响应码所有服务都需支持的否定响应码具体的服务需要支持的否定响应码否定响应码定义及其取值 USD诊断服务的否定响应中包含有导致否定响应原因的编码,称为否定响应码(NRC, Negative Response Code)。否定响应码的取值范围为0x00 - 0xFF,被分为三组: 0x00:服务器内部实现否定响应码判断逻辑时使用,表示要给出肯定响应。 0x01 – 0x7F:诊断通信相关的否定响应码。 0x80 – 0xFF:服务器收到诊断服务请求时,由于某些条件不满足要求而给出的否定

闲聊汽车软件开发 4万+

android.support.percent.PercentRelativeLayout 百分比界面

范例: &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.percent.PercentRelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.c...

surferjin的博客 1426

Arm Neoverse CMN-700 SLC内存系统与缓存分区技术解析

现代处理器架构中,缓存一致性协议与内存子系统设计直接影响系统性能。Arm Neoverse CMN-700采用的SLC(System Level Cache)通过16-way组相联设计实现高效数据缓存,其物理地址索引机制支持灵活的way分区配置。在软件可配置内存(OCM)模式下,SLC可作为独立内存空间使用,通过寄存器控制实现模式切换与区域锁定。缓存分区技术则通过请求源分类和way-based分配策略,满足实时性任务与吞吐量场景的不同需求。这些技术在5G基站、边缘计算等低延迟场景中具有重要应用价值,特别是C

weixin_30263073的博客 635

Android 百分比布局库适配(percent-support-lib) 解析与扩展

文章目录一、概述二、使用三、源码分析三、实现PercentLinearlayout 一、概述 周末游戏打得过猛,于是周天熬夜码代码,周一早上浑浑噩噩的发现android-percent-support-lib-sample这个项目,Google终于开始支持百分比的方式布局了,瞬间脉动回来,啊咧咧。对于这种历史性的时刻,不出篇博客难以表达我内心的激动。 还记得不久前,发了篇博客:Android 屏幕适配方案,这篇博客以Web页面设计引出一种适配方案,最终的目的就是可以通过百分比控制控件的大小。当然了,存在一些

Venus 的博客 843

傻白入门芯片设计,芯片键合(Die Bonding)(四)

傻白入门芯片设计,芯片键合(Die Bonding)(四) 引线键合、倒装芯片键合、管脚贴合技术

qq_46675545的博客 3万+

SAP_PP模块中MRP中信号灯简介

一、信号灯的作用二、常见的信号灯颜色及含义三、信号灯的来源四、常见场景示例示例1:物料满足所有需求示例2:生产订单已延迟示例3:缺料或未产生计划订单五、相关事务码参考六、如何应对红色或黄色信号灯?七、前台操作说明在 SAP PP 模块中,**MRP(物料需求计划)运行结果中的“信号灯”是一种非常直观的可视化提示工具,用于帮助用户快速识别物料计划是否存在异常或需要关注的问题。这些信号灯通常出现在MD04(库存/需求清单)、MD05(单物料MRP清单)、MD07(MRP列表)**等事务代码的界面中。

我小时候很黑的博客 665

Android 增强版百分比布局库 为了适配而扩展

针对Android程序员,我这边给大家整理了一些资料,包括不限于高级UI、性能优化、架构师课程、NDK、混合式开发(ReactNative+Weex)微信小程序、Flutter等全方面的Android进阶实践技术;希望能帮助到大家,也节省大家在网上搜索资料的时间来学习,也可以分享动态给身边好友一起学习!Android前沿技术大纲全套体系化高级架构视频Android高级架构资料、源码、笔记、视频。

2401_84149505的博客 434

基于STM32设计的心率脉搏测量仪(项目资料ID:9)

本设计基于STM32F103单片机开发了一款便携式心率脉搏测量仪,通过光电传感器采集脉搏信号,经放大(约1200倍)、滤波(低通及四阶低通滤波)、比较及偏置电压调理后,由STM32进行ADC采样与数据处理。硬件采用Altium Designer设计,包含信号调理电路(限定心率范围43.4-800次/分钟)及电源管理模块;软件基于STM32CubeMX开发,利用队列存储和时间间隔平均算法优化精度,实现多终端显示(OLED实时心率/动画、MATLAB波形分析、蓝牙传输至手机)。系统支持自动启停(检测脉搏启

以培养嵌入式工程师为己任 1万+

Android百分比布局支持库介绍——com.android.support:percent

库下载地址 : https://github.com/JulienGenoud/android-percent-support-lib-sample 在此之前,相信大家都已经对Android API所提供的布局方式非常熟悉了。也许在接触Android的时候都有过这样的想法,如果可以按照百分比的方式进行界面布局,这样适配各种屏幕就简单多了吧!!以前的一个小梦想,现在终于得以实现,谷

u010474556的专栏 660

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

android percent布局导入库,Android百分比布局支持库介绍——com.android.support:percent...

库下载地址 : https://github.com/JulienGenoud/android-percent-support-lib-sample在此之前,相信大家都已经对Android API所提供的布局方式非常熟悉了。也许在接触Android的时候都有过这样的想法,如果可以按照百分比的方式进行界面布局,这样适配各种屏幕就简单多了吧!!以前的一个小梦想,现在终于得以实现,谷歌正式提供百分比布局...

weixin_42620563的博客 566

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

简述Android 百分比布局支持库(android-percent-support)

一、概述Google 屏幕适配问题一直是纠结的问题 ,现在好了 官方提供了百分比布局可以完美的解决这样的适配问题. 我今天参考前辈的概述来,简单说一说百分比布局! 竖屏: 横屏: 从这两个图可以清晰地看出,这的确是适配屏幕的,是按照屏幕的宽高来对控件进行不同比例的设置。Eclipse: 可以在sdk目录下就可以找到对应的jar包; Android Studio : 在build.

粪乧的野蛮成长记录 5585

贝叶斯统计 [韦来生编]

贝叶斯(Bayes)统计是近几十年来迅速发展起来的数理统计的一个重要分支。贝叶斯方法与经典统计方法的主要不同之处是进行统计推断时除了利用样本信息外,还要利用参数的先验信息,因此可以提高统计推断或统计决策的效果。它在经济、金融、生物、医学、自然科学和社会科学等许多领域具有广泛的应用。贝叶斯方法的研究已渗透到了统计学的几乎所有领域。作者在给中国科学技术大学概率论与数理统计专业本科生开设的“数理统计”课程中有一章专门讲授“贝叶斯方法和统计决策理论”,近十年来也给中国科学技术大学概率统计专业研究生开设过几次“贝叶斯分析”课。本书是在对过去讲稿的内容作了适当的增减和调整的基础上完成的。  本书共分六章。第1章是绪论,介绍了贝叶斯统计的若干基本概念,同时对必要的数理统计的基础知识有重点地作了回顾。第二章介绍了确定先验分布的若干可供选择的方法。第三章介绍了几类常见统计模型参数的后验分布的主要结果和计算方法。第四章和第五章分别介绍了“贝叶斯统计推断”和“贝叶斯统计决策”的内容。第六章介绍了贝叶斯统计计算的若干方法,包括蒙特卡洛方法和马尔可夫链蒙特卡洛(MCMC)方法以及相关统计软件的简介。本书的每一章附右大量的例题和习题,书末附有常用的几个表格和部分习题解答供读者查用。  大约可在54学时内讲授本书的第1章至第六章的主要内容,教师可根据学时需要选讲本书第1章至第六章的部分内容。书中标“*”号的章节可略去不讲,留给读者作为阅读材料。第六章例题中的R代码和部分例题的数据文件等可从作者个人主页下载。  作者在编写本书的过程中参考了J.O.Berger教授的《统计决策论及贝叶斯分析》和茆诗松教授编写的《贝叶斯统计》等书中的一些内容,以及《贝叶斯分析》一书中由张伟平博士编写的有关贝叶斯统计计算的一些内容。在此表示衷心感谢。  本书编写准备过程中,中国科学技术大学统计与金融系的几个研究生帮助完成了本书部分中文的录入和排版,作者对他们的辛勤工作表示真诚的感谢。高等教育出版社为本书的出版给予了大力支持。在此一并致谢。

Android百分比布局支持库 com.android.support:percent

要想在Android中使用百分比进行布局,首先要导入library.  com.android.support:percent 使用方法介绍: 百分比控件布局分为两种:PercentFrameLayout   和   PercentRelativeLayout 顾名思义都是继承了FrameLayou和RelativeLayout 从源码中可以看出,百分比类库支持的属性有如下这些

a921545792的专栏 968

Android Support库百分比布局 com.android.support:percent:22.2.0 附带Eclipse教程

先来一个demo的路径 https://github.com/JulienGenoud/android-percent-support-lib-sample 不过是android Studio的 在\extras\android\m2repository\com\android\support的目录下..你会发现你会有一个Percent文件夹..这就是google官方对百分比布局的依赖文

HelloWorld_Bean 5306

Android 百分比布局支持库使用

Android 百分比布局支持库com.android.support:percent使用Android 百分比布局支持库comandroidsupportpercent使用 概述

Scott Wang 912

Android 百分比布局库(percent-support-lib) 解析与扩展

转载请标明出处:  http://blog.csdn.net/lmj623565791/article/details/46695347;  本文出自:【张鸿洋的博客】 一、概述 周末游戏打得过猛,于是周天熬夜码代码,周一早上浑浑噩噩的发现android-percent-support-lib-sample这个项目,Google终于开始支持百分比的方式布局了,瞬间脉动回来,

lcj1008的专栏 604

Android 百分比布局库(percent-support-lib)

http://blog.csdn.net/lmj623565791/article/details/46695347;  本文出自:【张鸿洋的博客】 一、概述 周末游戏打得过猛,于是周天熬夜码代码,周一早上浑浑噩噩的发现android-percent-support-lib-sample这个项目,Google终于开始支持百分比的方式布局了,瞬间脉动回来,啊咧咧。对于这

Zhangxuexue_的博客 757

Android官-按百分比来设置控件的宽高

我做了一个新的百分比支持库的示例。 需要引用 包:'com.android.support:percent:22.2.0' 它将很快就会记录在android开发网站,它只是一个概念验证 你可以在这里检查官方文档引用 这个库提供基于百分比的布局,同时水平和垂直。 简单的结果 复杂的结果 如何使用: 就百分比支持库添加到您的项目 depende

wblobin的博客 3319
上一篇: Android主题切换—夜间/白天模式探究
下一篇: Android中使用SVG矢量图(一)
Sunzxyong
博客等级 码龄14年 1430粉丝 131原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值