Android 布局开发之百分比布局、弹性布局

news/2024/7/7 13:12:20

1.百分比布局
很简单,超级简单。引用之后就可以使用了。

compile 'com.android.support:percent:23+'

git地址:
https://github.com/JulienGenoud/android-percent-support-lib-sample.git

注意:使用的时候,百分比布局只对他包含的一级有用。就是直属子布局有用。上代码:

<?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">
<com.google.android.flexbox.FlexboxLayout
    xmlns:fle="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_heightPercent="80%"
    app:layout_widthPercent="80%"
    android:background="@color/colorAccent"
    app:flexWrap="wrap"
    app:alignItems="flex_start"
    app:alignContent="flex_start" >
        <android.support.percent.PercentFrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >
                <TextView
                    android:layout_width="0dp"
                    android:text="aaaasdfsadfasdfsa"
                    app:layout_heightPercent="20%"
                    app:layout_widthPercent="20%"
                    android:layout_height="0dp" />



        </android.support.percent.PercentFrameLayout>

        <android.support.percent.PercentFrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >
                <TextView
                    android:layout_width="0dp"
                    android:text="aaaasdfsadfasdfsa"
                    app:layout_heightPercent="20%"
                    app:layout_widthPercent="20%"
                    android:layout_height="0dp" />

        </android.support.percent.PercentFrameLayout>
</com.google.android.flexbox.FlexboxLayout>
</android.support.percent.PercentFrameLayout>

也就是说只能对她的直属下一级起作用。

2.弹性布局:

compile 'com.google.android:flexbox:0.1.3'

git:
https://github.com/google/flexbox-layout.git

转载于:https://www.cnblogs.com/caoxinyu/p/6647864.html


http://www.niftyadmin.cn/n/4482038.html

相关文章

幸福的生日

明天即将踏上工作的旅程&#xff0c;妈妈将我的生日提前&#xff0c;中午爸妈请我们一起吃海底捞给我庆祝生日。 中午12点到位于家不远的华商海底捞&#xff0c;这是第一次吃海底捞的地方&#xff0c;也是吃的最多次的地方&#xff0c;对这有特殊的感情。生意一如既往的好&…

7_6 带宽(UVa140)回溯法:最优性剪枝

给定一个图(V,E)&#xff0c;其中V为顶点的集合&#xff0c;E为边的集合&#xff0c;属于VxV。给定V中元素的一种排序&#xff0c;那么顶点v的带宽定义如下&#xff1a;在当前给定的排序中&#xff0c;与v距离最远的且与v有边相连的顶点与v的距离。给定排序的带宽定义为各顶点带…

经典的菜单显示隐藏代码

1.按钮上的click事件 &#xff1a; 控制菜单的显示隐藏,同时需要阻止事件冒泡到document&#xff1b; 2.document的click事件&#xff1a; 让menu隐藏,这个功能是点击document任意一处,将菜单隐藏&#xff1b; 3.菜单的click事件&#xff1a;菜单本身并没有&#xff0c;是菜单内…

表连接、TSQL基本编程、存储过程

表连接&#xff1a;将多个表的数据一次性查询出来&#xff0c;共同显示 子查询方式&#xff1a; select (select 列 from 名where 名.列 名.列&#xff09;列 from 名 笛卡尔积&#xff1a; select 列&#xff0c;列from 名&#xff0c;名 where 名.列 名.列 join on&#xf…

sql递归查询 根据Id查所有子结点

Declare Id Int Set Id 0; ---在此修改父节点 With RootNodeCTE(D_ID,D_FatherID,D_Name,lv) As ( Select D_ID,D_FatherID,D_Name,0 as lv From [LFBMP.LDS].[dbo].[LDS.Dictionary] Where D_FatherID In (Id) Union All Select [LFBMP.LDS].[dbo].[LDS.Dictionary].D_ID,[L…

C#使用二叉树算法设计一个无限分级的树表

效果图&#xff1a; 数据库&#xff1a; 操作树的示意图&#xff1a; 控制器代码&#xff1a; using Dw.Business; using Dw.Entity; using Dw.Utilities; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web.Mvc; usin…

sql server 2008r2 清除数据库日志

USE [master] GO ALTER DATABASE data SET RECOVERY SIMPLE WITH NO_WAIT GO ALTER DATABASE data SET RECOVERY SIMPLE --简单模式 GO USE data GO DBCC SHRINKFILE (Ndata_log , 11, TRUNCATEONLY) GO USE [master] GO ALTER DATABASE data SET RECOVERY FULL W…

js基础和dom操作

1、HTML元素标记 - 超文本标记语言 决定你网页中有哪些东西 2、CSS - 样式表 决定你网页中的这些元素标记的样式和布局用&#xff1a;<style type"text/css"></style> 3、JS - JavaScript 决定你网页中的这些元素标记的功能和特效。只要放在HTML里就可以…