移动客户端Android技术知识Android开发

Android Flutter:这是一份全面 & 详细的 布局组

2020-09-22  本文已影响0人  Carson带你学安卓

前言

示意图

今天,我主要讲解Flutter中布局方面的组件Widget,类型如下,希望你们会喜欢。

示意图

1. 边距属性

主要包括:padding、margin、alignment

1.1 padding属性

// 1. 所有方向均使用相同数值的填充。
all(double value) 
// 示例:4个方向各添加16像素补白
padding: EdgeInsets.all(16.0)

// 2. 分别指定四个方向的不同填充
fromLTRB(double left, double top, double right, double bottom)
// 示例:
padding: const EdgeInsets.fromLTRB(10,20,30,40)

// 3. 设置具体某个方向的填充(可以同时指定多个方向)
only({left, top, right ,bottom })
// 示例:在左边添加8像素补白
padding: const EdgeInsets.only(left: 8.0),

// 4. 设置对称方向的填充
// vertical:针对垂直方向top、bottom
// horizontal:针对横向方向left、right
symmetric({ vertical, horizontal })
// 示例:垂直方向上下各添加8像素补白
padding: const EdgeInsets.symmetric(vertical: 8.0)

1.2 margin属性

// 1. 所有方向均使用相同数值的填充。
all(double value) 
// 示例:4个方向各添加16像素补白
margin: EdgeInsets.all(16.0)

// 2. 分别指定四个方向的不同填充
fromLTRB(double left, double top, double right, double bottom)
// 示例:
margin:const EdgeInsets.fromLTRB(10,20,30,40)

// 3. 设置具体某个方向的填充(可以同时指定多个方向)
only({left, top, right ,bottom })
// 示例:在左边添加8像素补白
margin:const EdgeInsets.only(left: 8.0),

// 4. 设置对称方向的填充
// vertical:针对垂直方向top、bottom
// horizontal:针对横向方向left、right
symmetric({ vertical, horizontal })
// 示例:垂直方向上下各添加8像素补白
margin:const EdgeInsets.symmetric(vertical: 8.0)

1.3 alignment

// 居中 & 各方向对齐
center
centerLeft
centerRight

// 底部对齐 & 各方向对齐
bottomCenter
bottomLeft
bottomRight

// 顶部对齐 & 各方向对齐
topCenter
topLeft
topRight

// 示例
alignment:Alignment.center

2. 基础布局组件

主要包括:

具体请看文章:Android Flutter:那些不可忽视的基础布局!


3. 列表布局组件

Flutter常用的滚动型列表组件包括:GridView组件 + ListView组件

具体请看文章:


4. 导航栏组件

主要包括:

具体请看文章:


5. 总结


请点赞!因为你们的赞同/鼓励是我写作的最大动力!

相关文章阅读
Android开发:最全面、最易懂的Android屏幕适配解决方案
Android开发:史上最全的Android消息推送解决方案
Android开发:最全面、最易懂的Webview详解
Android开发:JSON简介及最全面解析方法!
Android四大组件:Service服务史上最全面解析
Android四大组件:BroadcastReceiver史上最全面解析


欢迎关注Carson_Ho的简书!

不定期分享关于安卓开发的干货,追求短、平、快,但却不缺深度

上一篇 下一篇

猜你喜欢

热点阅读