import 'package:flutter/material.dart';
void main () {
runApp(myApp());
}
class myApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
title: 'GridView',
home: Scaffold(
appBar: AppBar(
title: Text('我是导航栏'),
),
body: GridView.count(
padding: EdgeInsets.fromLTRB(10, 20, 10, 30), // GridView 的外边距
crossAxisSpacing: 10.0, // 每格横向间隔
mainAxisSpacing: 30, // 每格纵向间隔
crossAxisCount: 3, // 有几列
childAspectRatio:0.8, // 宽高比
// scrollDirection: Axis.horizontal, // 纵横向
children: <Widget>[
Image.network('https://i0.hdslb.com/bfs/sycp/creative_img/202005/326e264bf254a9d9983712ed5bdd7926.jpg',fit: BoxFit.cover,),
Image.network("https://i0.hdslb.com/bfs/archive/a36b455619b07da7157544d84f76eeb039d5d8e6.jpg@336w_190h.jpg",fit: BoxFit.cover,),
Image.network("https://i1.hdslb.com/bfs/archive/4d6fa50c19a34c9c647449654a238015a8cefa5f.jpg@336w_190h.jpg",fit: BoxFit.cover,),
Image.network("https://i2.hdslb.com/bfs/archive/6411ba2693ed69ee88b6b9c7f9b67aa3cbe4a171.jpg@336w_190h.jpg",fit: BoxFit.cover,),
Image.network("https://i1.hdslb.com/bfs/archive/ee3459bf8319d22ad49d9dadac89c2adddd8251f.jpg@336w_190h.jpg",fit: BoxFit.cover,),
Image.network("https://i2.hdslb.com/bfs/archive/6411ba2693ed69ee88b6b9c7f9b67aa3cbe4a171.jpg@336w_190h.jpg",fit: BoxFit.cover,),
],
)
)
);
}
}
Flutter - GridView(5)
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...