【发布时间】:2021-10-01 22:24:35
【问题描述】:
我几乎完成了我的应用程序的实现,现在我正在使它更具响应性,但我发现了一个问题。我正在使用三个模拟器(Pixel 2、Pixel 4 和 Nexus 4)以及我的手机(Galaxy S10+)。这是问题:
左边第一个是我的模拟器(Pixel 4),右边第二个是我的手机(S10+)。看到问题了吗?位置以某种方式发生了变化,两者具有相同的纵横比(19:9)和默认分辨率(1080x2280)。那么这里发生了什么?我将只为一张图片添加代码(带有放大镜的那个球体,如果适用于一张,其余的都可以):
body: LayoutBuilder(builder: (context, constraints) {
return Container(
child: SingleChildScrollView(
child: Stack(children: [
Container(
width: constraints.maxWidth,
height: constraints.maxHeight <= 592
? constraints.maxHeight * 3.6
: constraints.maxHeight * 2.7,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
'https://i.imgur.com/SdLahrV.png'),
fit: BoxFit.cover))),
Wrap(
children: [
Container(
margin: EdgeInsets.only(
left: constraints.maxWidth >= 380 &&
constraints.maxHeight >= 500
? constraints.maxWidth * 0.02
: constraints.maxWidth * 0.04,
top: constraints.maxHeight >= 592
? constraints.maxHeight * 0.22
: constraints.maxHeight * 0.35),
height: constraints.maxHeight * 0.14,
width: constraints.maxWidth * 0.24,
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TelaConhecMangue_(),
),
);
},
child: Image(
image: NetworkImage(
'https://i.imgur.com/HmwwpOb.gif')),
),
),
],
),
],
),
),
);
}
);
提前致谢
【问题讨论】:
标签: flutter android-emulator flutter-layout responsiveness