zoukankan      html  css  js  c++  java
  • Android Activity切换(跳转)时出现黑屏的解决方法

     

    在两个Activity跳转时,由于第二个Activity在启动时加载了较多数据,就会在启动之前出现一个短暂的黑屏时间,解决这个问题比较简单的处理方法是将第二个Activity的主题设置成透明的,这样在启动第二个Activity时的黑屏就变成了显示第一个Activity界面。这个分两步完成:
    第一步:xxx/res/values/styles.xml中加入自定义Activity的Theme,如下所示:

    [html]  <style name="Transparent" parent="android:Theme.Light">
            <!--将Activity的Theme设置成透明-->
            <item name="android:windowIsTranslucent">true</item>
        </style>

    <style name="Transparent" parent="android:Theme.Light">
            <!--将Activity的Theme设置成透明-->
            <item name="android:windowIsTranslucent">true</item>
        </style>第二步:在AndroidManifest.xml中将第二个Activity的"android:theme"属性设置成刚才自定义的主题样式。如下所示:

    [html]  <activity
        android:name="com.yutao.customer.CustomerActivity"
        android:label="@string/app_name"
        android:theme="@style/Transparent">

            <activity
                android:name="com.yutao.customer.CustomerActivity"
                android:label="@string/app_name"
                android:theme="@style/Transparent">    到此应该就不会出现那个讨厌的黑屏了。

  • 相关阅读:
    感觉每天打开自己的博客园, 想编程的心情就多了起来~~~
    算法图解相关代码整理
    github cli
    What's WebFlux ? And how to use it ? 一股有咖喱味的WebFlux简介
    style
    gradle 1
    gradle打包可运行jar
    外面下着雨
    天晴朗 看花儿多多开放
    Full Stack Reactive with React and Spring WebFlux
  • 原文地址:https://www.cnblogs.com/zmc/p/4079646.html
Copyright © 2011-2022 走看看