首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >android-百分比布局

android-百分比布局

作者头像
tea9
发布2022-07-16 15:36:25
发布2022-07-16 15:36:25
8710
举报
文章被收录于专栏:tea9的博客tea9的博客
代码语言:javascript
复制
//引包
compile 'com.android.support:percent:24.2.1'


<android.support.percent.PercentFrameLayout
    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/button1"
        android:text="Button 1"
        android:layout_gravity="left|top"
        app:layout_widthPercent="50%"
        app:layout_heightPercent="50%"/>

    <Button
        android:id="@+id/button2"
        android:text="Button 2"
        android:layout_gravity="right|top"
        app:layout_widthPercent="50%"
        app:layout_heightPercent="20%"/>
</android.support.percent.PercentFrameLayout>

使用PercentFrameLayout 需要把完整包名路径写出来 还需要定义一个app的命名空间

PercentFrameLayout会继承FrameLayout

还有一个PercentRelativeLayout 继承了RelativeLayout中所有属性

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档