【问题标题】:Grid View elements are getting cropped on home Screen?网格视图元素在主屏幕上被裁剪?
【发布时间】:2020-05-02 04:30:30
【问题描述】:

我的主屏幕上有一个可滚动的网格视图,其中包含几个容器。然而,这个网格视图由于它所包裹的容器的高度而被裁剪。容器是列的一部分,列是堆栈的一部分。

【问题讨论】:

    标签: user-interface flutter gridview dart user-experience


    【解决方案1】:

    使用Expanded

    Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          SizedBox(height: 20),
          Text(
            "Hello,",
            style: TextStyle(
                fontFamily: "Netflix",
                fontWeight: FontWeight.w600,
                fontSize: 32,
                letterSpacing: 0.27,
                color: Color(0xFFFF8C3B).withOpacity(0.7),
            ),
          ),
          SizedBox(height: 4),
          name(context),
          SizedBox(height: 40),
          Text(
            "Home",
            style: TextStyle(
              fontFamily: "Netflix",
              fontWeight: FontWeight.w600,
              fontSize: 35,
              letterSpacing: 0.27,
              color: Color(0xFFFF8C3B),
            ),
          ),
          SizedBox(height: 15),
          Expanded( //TODO: Use Expanded here
            child: GridView.builder(
              itemCount: homeList.length,
              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 2, mainAxisSpacing: 20,
              ),
              itemBuilder: (ctx, i) {
                return GestureDetector(
                  onTap: () {
                    if (i == 0) {
                      _interstitialAd.show();
                    } else if (i == 1) {
                      FlutterPollfish.instance.show();
                    } else if (i == 2) {
                      sendInvite();
                    }
    

    【讨论】:

    • 我试过了,但它仍然没有将gridview扩展到页面底部。
    • 您是否删除了 Containerheight: MediaQuery.of(context).size.height / 3 属性?
    • 是的,我用 Expanded 替换了它。
    • 移除 Positioned 小部件。你在那里设置bottom: 70.0
    • 酷。在我进行这些更改并设置 flex 属性后工作得很好。
    猜你喜欢
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 2020-04-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-10
    • 1970-01-01
    • 2014-07-29
    相关资源
    最近更新 更多