小编Giu*_*nci的帖子

Android 12 中是否有可能获得未裁剪的启动屏幕?

在早于 Android 12 的 Android 版本上,我可以轻松构建带有未裁剪图像的启动屏幕。例如 Android 11 上是这样的:

Android 11 上的启动屏幕

然而,Android 12 引入了新的启动屏幕 API,我不知道如何在 Android 12 中重现上面的启动屏幕。它似乎总是被裁剪,在 Android 12 上结果如下:

Android 12 上的启动屏幕

这是我android/src/main/res/values/styles.xml的旧 Android 版本(例如 Android 11):

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">@drawable/launch_background</item>
        <item name="android:windowFullscreen">false</item>
    </style>
    <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">?android:colorBackground</item>
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

这是我android/src/main/res/values-v31/styles.xml的 Android 12:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowSplashScreenAnimatedIcon">@drawable/launch_background</item>
        <item name="android:windowFullscreen">false</item>
    </style>
    <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">?android:colorBackground</item>
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

两者之间的唯一区别styles.xml是我用于android:windowSplashScreenAnimatedIconAndroid 12 和android:windowBackground旧版 Android 版本,如新启动屏幕 …

android-12

5
推荐指数
1
解决办法
3166
查看次数

使用“cast”方法和“as”关键字进行转换之间的区别

as在 Dart 中,使用关键字进行转换和使用方法进行转换有什么区别cast

请参见以下示例:

import 'dart:convert';

class MyClass {
  final int i;
  final String s;

  MyClass({required this.i, required this.s});

  factory MyClass.fromJson(Map<String, dynamic> json) =>
      MyClass(s: json["s"], i: json["i"]);
}

void main() {
  const jsonString = '{"items": [{"i": 0, "s": "foo"}, {"i": 1, "s":"bar"}]}';
  final json = jsonDecode(jsonString);

  final List<MyClass> thisWorks = (json["items"] as List)
      .cast<Map<String, dynamic>>()
      .map(MyClass.fromJson)
      .toList();

  final List<MyClass> thisAlsoWorks = (json["items"] as List)
      .map((json) => MyClass.fromJson(json as Map<String, dynamic>))
      .toList();

  final List<MyClass> thisCrashes =
      (json['items'] …
Run Code Online (Sandbox Code Playgroud)

dart flutter

5
推荐指数
1
解决办法
2082
查看次数

标签 统计

android-12 ×1

dart ×1

flutter ×1