Android 布局開發之百分比布局 彈性布局

2021-07-13 08:15:58 字數 1484 閱讀 2742

1.百分比布局

很簡單,超級簡單。引用之後就可以使用了。

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

注意:使用的時候,百分比布局只對他包含的一級有用。就是直屬子布局有用。上**:

<?xml version="1.0" encoding="utf-8"?>

.support

.percent

.percentframelayout

xmlns:android=""

android:layout_width="match_parent"

android:layout_height="match_parent">

.google

.android

.flexbox

.flexboxlayout

xmlns:fle=""

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/coloraccent"

.support

.percent

.percentframelayout

android:layout_width="match_parent"

android:layout_height="match_parent"

>

"0dp"

android:text="aaaasdfsadfasdfsa"

android:layout_height="0dp" />

.support

.percent

.percentframelayout>

.support

.percent

.percentframelayout

android:layout_width="match_parent"

android:layout_height="match_parent"

>

"0dp"

android:text="aaaasdfsadfasdfsa"

android:layout_height="0dp" />

.support

.percent

.percentframelayout>

com.google

.android

.flexbox

.flexboxlayout>

.support

.percent

.percentframelayout>

也就是說只能對她的直屬下一級起作用。

2.彈性布局:

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

android 百分比布局

為了更好的與碎片化戰鬥,android團隊終於推出百分比支援庫 這個庫是非常容易使用的,因為它就如同 relativelayout 和 framelayout 一樣我們都熟悉,只是有一些額外的功能。在gradle中新增依賴 compile com.android.support percent 23...

百分比布局

參考位址 螢幕的適配是我們android開發最經常做的事情之一,我們一直指望著能夠一套布局適配所有。於是在android5.0之後,提供了android support percent lib,這樣我們可以盡情的使用。使用的時候,我們嗯需要設定的有 layout marginpercent layo...

百分比布局

其中相對布局和幀布局官方是有支援庫的 compile com.android.support percent 25.3.0 但線性布局並沒有 public class percentlinearlayout extends linearlayout override protected void o...