首页 > 解决方案 > 颤动中的android版本或像素问题?

问题描述

我是 Flutter 应用程序开发的初学者(约 1 个月)。我在代码中遇到错误,其中相同的代码在像素 2XL(尺寸:- 5.99,API -:29)中运行良好,但是当我在 Galaxy Nexus 中运行相同的代码时(尺寸-:4.65,API-:23 ) 它的运行方式不同。在此处输入图像描述这是像素 2XL 中的简单页面 在此处输入图像描述 这是银河系中的同一页面

import 'package:flutter/material.dart';


class page1 extends StatefulWidget {
  @override
  _page1State createState() => _page1State();
}

class _page1State extends State<page1> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.blue,
        body: Container(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisSize: MainAxisSize.max,
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                Container(
                  height: 300,
                  width: 200,
                  child: Image.asset(
                    'assets/oreo.png',
                    fit: BoxFit.fitHeight,
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(left: 15),
                  child: Row(
                    children: <Widget>[
                      Column(
                        children: <Widget>[
                          Text(
                            "mytime is an initiative",
                            style: TextStyle(
                              fontSize: 20,
                              fontWeight: FontWeight.w300,
                              letterSpacing: 2.5,
                              color: Colors.white,
                            ),
                          ),
                          Text(
                            "by XYZ Texhnologies",
                            style: TextStyle(
                              fontSize: 20,
                              fontWeight: FontWeight.w300,
                              letterSpacing: 2.5,
                              color: Colors.white,
                            ),
                          ),
                          Text(
                            "to provide quality",
                            style: TextStyle(
                              fontSize: 20,
                              fontWeight: FontWeight.w300,
                              letterSpacing: 2.5,
                              color: Colors.white,
                            ),
                          ),
                          Text(
                            "programming education to people",
                            style: TextStyle(
                              fontSize: 20,
                              fontWeight: FontWeight.w300,
                              letterSpacing: 2.5,
                              color: Colors.white,
                            ),
                          ),
                      
                          SizedBox(height: 20,),
                        ],
                      ),
                    ],
                  ),
                ),
              ],
            ),
        ),
    );
  }
}

这是页面的代码。

我不知道为什么会这样。谁能帮我这个?先感谢您。

标签: androidflutterandroid-layoutflutter-layout

解决方案


黄色,黑色的条带表示您“溢出”。溢出意味着元素对于它的容器来说太大了。

在您的特定情况下,文本字体和间距太大,并且在更改手机时,因为您没有动态设置它以适应不同的屏幕尺寸,它超出了边界。

您可以减小字体大小或动态设置。

如果你是 Flutter 新手,我推荐这门课程来学习这些基础知识。

--> https://www.udemy.com/course/learn-flutter-dart-to-build-ios-android-apps/

我自己拿了它,它得到了很好的解释,从像这样的基础主题到困难的主题。

希望这对您有所帮助,而不仅仅是回答问题。


推荐阅读