android support Library—-Percent Support Library

本文介绍如何使用Android的PercentSupportLibrary进行UI设计,利用百分比布局实现更灵活的界面适配。通过PercentFrameLayout和PercentRelativeLayout两个核心组件,开发者能够轻松创建响应式布局。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用Android提供的支持库-Percent Support Library,可以让我们使用百分比来制作ui界面,更加方便我们适配。

官方链接: https://developer.android.com/topic/libraries/support-library/features.html#recommendation

目前仅支持PercentFrameLayout和PercentRelativeLayout两种布局,git上有别人写的关于LinearLayout的扩展。
具体使用: :

 <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">
     <ImageView
         app:layout_widthPercent="50%"
         app:layout_heightPercent="50%"
         app:layout_marginTopPercent="25%"
         app:layout_marginLeftPercent="25%"/>
 </android.support.percent.PercentRelativeLayout>

其他属性有:
相关xml属性

最好自己看源码,实现其他ViewGroup的实现! 共勉!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值