【发布时间】:2020-10-08 09:52:59
【问题描述】:
规格: 模拟器; Nexus 7 (2012) 7.0 800x1280 hdpi; Android 4.4 x86(为旧系统开发应用)
我正在开发一个应用程序并放置了一张背景图片,如下图所示。图像已自然创建为 800x1280。请注意左下角的“BOOOYA”文本(编辑:Booya 文本的目的是表明将某物定位在零零处不会将其放置在屏幕底部,而是位于图像底部):
我不确定屏幕底部的蓝条发生了什么。我知道这是Scaffold 的背景颜色,但考虑到我选择背景图像为Boxfit.fit,我不知道它为什么会显示。我尝试将Boxfit 更改为不同的选项,但这并没有改变下面空间中发生的情况。它似乎只是一个死空间,除了它的颜色,我无法影响它。
请对为什么会发生这种情况有任何建议吗?谢谢。
@override
Widget build(BuildContext context) {
return GestureDetector(
onTapDown: (TapDownDetails details) => _onTapDown(details),
child: Scaffold(
backgroundColor: Colors.blue,
body: currentLocation != null
? Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("lib/pages/assets/images/road_map.png"),
fit: BoxFit.fill,
),
),
child: Stack(
children: <Widget>[
Positioned(
//We have the "?? -100" so we don't get a null error on load
//TODO: the "+3 -4" need to be sorted. Not center without it
//Is this an image problem or a lastTouch problem?
top: (lastTouchLogicalY + 4 - image.width / 2) ?? -100,
left: (lastTouchLogicalX - 3 - image.height / 2) ?? -100,
child: Image.asset(
'lib/pages/assets/images/dot1.png',
),
),
Positioned(
//We have the "?? -100" so we don't get a null error on load
//TODO: the "+3 -4" need to be sorted. Not center without it
//Is this an image problem or a lastTouch problem?
top: currentPositionY - doomGuy.width,
left: currentPositionX - doomGuy.height / 2.5,
child: Image.asset(
'lib/pages/assets/images/doomguy1.png',
),
),
Positioned(
//We have the "?? -100" so we don't get a null error on load
top: textBoxOffsetY ?? -100,
left: textBoxOffsetX ?? -100,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(10)),
border: Border.all(
color: Colors.black,
width: 2,
)),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'To Sign: ${distanceToStop.toStringAsFixed(0)}m',
style: TextStyle(
color: Colors.black,
fontSize: 20,
),
),
Text(
'To DoomGuy: ${distanceToDoomGuy.toStringAsFixed(0)}m',
style: TextStyle(
color: Colors.black,
fontSize: 20,
),
),
],
),
),
),
),
Positioned(
left: 0,
bottom: 0,
child: Text("BOOOOYYAAAA"),
),
],
),
)
: Text(
"SPOOOOOOKY!!!",
style: TextStyle(fontSize: 50),
),
),
);
}
}
【问题讨论】:
-
如果我们将容器高度设置为 double.infinity 会怎样?
-
请检查您的图像是否从底部不透明?
-
关于BOOOYA文字,你想去哪里?
-
道歉... Booya 文本的目的是表明将某物定位在零零位置不会将其放在屏幕底部,而是放在图像底部。
-
你确定那个蓝色区域不是安卓手机的返回键所在的地方吗?