Android动画相关 -- 转场动画白屏问题

一.解决转场动画白屏问题

  1. 添加 WelcomTheme 主题

AndroidManifest.xml

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/WelcomTheme">

或者

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true">
        <activity
            android:name=".MainActivity"
            android:theme="@style/WelcomTheme">
  1. 在styles.xml中添加 WelcomTheme 的代码
    styles.xml
<style name="WelcomTheme" parent="AppTheme">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@mipmap/ic_launcher_round</item>
</style>

添加了一个 ic_launcher_round 的背景图

二、这样整个activity也会有此背景

采取设置activity的背景来解决
android:background="@color/colorWhite"

<color name="colorWhite">#FFFFFF</color>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorWhite"
    tools:context=".MainActivity">

猜你喜欢

转载自blog.csdn.net/LHshooter/article/details/107346438
今日推荐