zoukankan      html  css  js  c++  java
  • 【flutter 入门】listview

    横向

    // 展示ListView
    class horizontalList extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
    return ListView(
    scrollDirection: Axis.horizontal, //设置为横向,默认使纵向
    children: <Widget>[
    new ListItem(context,
    "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1381175915,2452671132&fm=200&gp=0.jpg"),
    new ListItem(context,
    "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1486063646,2273285260&fm=200&gp=0.jpg"),
    new ListItem(context,
    "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=174198655,918435950&fm=200&gp=0.jpg"),
    new ListItem(context,
    "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2970139869,654827709&fm=200&gp=0.jpg"),
    new ListItem(context,
    "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=768870055,119193172&fm=200&gp=0.jpg"),
    ],
    );
    }
    }

    2.嵌套 
    子listview需要有确切size 

     return SizedBox(

    // 不给高度的话显示不了哈, 就跟 android 里, scrollview 里嵌套 listview 一样, 要计算高度的意思, 这里我就先随便给个, 其实我觉得应该是要根据 item 的高度来算的, 但我现在不会算啊

    height: 100.0,

    child: ListView.builder(

    scrollDirection: Axis.horizontal,

    itemBuilder: (context, position) {

    return _buildHorItem(position);

    },

    itemCount: horList.length,

    ),

    );

    没有SizedBox 报错。

  • 相关阅读:
    .Net培训个人总结笔记1
    .Net培训个人总结笔记0——前言
    python访问数据库
    默认构造函数
    VC使用中一些常见问题
    使用VC进行调试
    sqlite3.OperationalError: Could not decode to UTF8 column XXX with text '***'
    cent os 5.5 安装
    initialization of xxx is skipped by xxx
    VC程序启动时隐藏主窗口
  • 原文地址:https://www.cnblogs.com/mamamia/p/14467370.html
Copyright © 2011-2022 走看看