美文网首页
百分比布局

百分比布局

作者: CPU_Easy | 来源:发表于2018-11-21 19:57 被阅读0次
<?xml version="1.0" encoding="utf-8"?>
<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/button_1"
        android:text="Button 1"
        android:layout_gravity="left|top"
        app:layout_widthPercent="50%"
        app:layout_heightPercent="50%"
        />

    <!--右上角-->
    <Button
        android:id="@+id/button_2"
        android:text="Button 2"
        android:layout_gravity="right|top"
        app:layout_widthPercent="50%"
        app:layout_heightPercent="50%"
        />

    <!--左下角-->
    <Button
        android:id="@+id/button_3"
        android:text="Button 3"
        android:layout_gravity="left|bottom"
        app:layout_widthPercent="50%"
        app:layout_heightPercent="50%"
        />

    <!--右下角-->
    <Button
        android:id="@+id/button_4"
        android:text="Button 4"
        android:layout_gravity="right|bottom"
        app:layout_widthPercent="50%"
        app:layout_heightPercent="50%"
        />
    </android.support.percent.PercentFrameLayout>

效果:

百分比布局.gif

文件结构:

xml文件

相关文章

  • 前端布局种类

    1、流式布局(百分比布局) 2、flex布局(百分比布局) 3、rem布局(百分比布局)

  • 响应式布局

    弹性布局 浮动+百分比布局 Flex布局 悬浮+百分比布局 浮动+百分比布局好处 网页内容宽度自适应 多设备都适用...

  • 流式布局

    流式布局(百分比布局) 流式布局就是百分比布局,也称为非固定像素布局 通过将盒子的宽度设置成百分比,从而根据屏幕的...

  • 移动端布局

    1.百分比布局 百分比布局, 也叫流式布局效果: 宽度自适应,高度固定。 2.Flex布局 Flex布局/弹性布局...

  • 响应式页面开发

    布局方式 固定布局 流式布局:流式布局是以百分比作为单位的,我们要牢记如下公式:百分比宽度 = 目标元素宽度 / ...

  • CSS真的很麻烦,把CSS语法学会了,提升你的编码能力还是绰绰有

    css3画热咖啡 css自适应布局方案 一、百分比布局宽度百分比,高度px布局 二、rem布局①自定义rem尺寸 ...

  • 移动Web开发中的常见布局方式及一些常见问题

    一、流式布局 1.1 什么是流式布局 流式布局就是百分比布局,通过盒子的宽度设置成百分比来根据屏幕的宽度来进行伸缩...

  • 布局小结

    布局方式 静态布局 浮动布局 定位布局 自适应布局 流式布局(百分比布局) 响应式布局 弹性布局 悬挂布局 圣杯布...

  • 布局

    今天学习了安卓的四种布局方式 线性布局 相对布局 帧布局 百分比布局

  • 移动端布局学习笔记_2019-04-05

    百分比与固定高度布局 前提是device-width为理想视口,然后通过水平方向百分比布局或者弹性布局,垂直方向一...

网友评论

      本文标题:百分比布局

      本文链接:https://www.haomeiwen.com/subject/uohhqqtx.html