Ano*_*ous 103 android splash-screen app-startup
我有一个Android应用程序,在启动时显示白色屏幕2秒.我的其他应用程序不这样做,但这个应用程序.我还实现了一个启动画面,希望能解决这个问题.我应该增加闪屏的睡眠时间吗?谢谢.
小智 155
把它放在自定义样式中,它解决了所有问题.使用hacky半透明修复将使您的任务栏和导航栏半透明,使闪屏或主屏幕看起来像意大利面条.
<item name="android:windowDisablePreview">true</item>
use*_*543 99
只需在AndroidManifest.xml文件中提及启动活动的透明主题即可.
喜欢:
<activity
android:name="first Activity Name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
并用Activity类代替扩展该屏幕AppCompatActivity.
喜欢 :
public class SplashScreenActivity extends Activity{
----YOUR CODE GOES HERE----
}
Run Code Online (Sandbox Code Playgroud)
Abh*_*bhi 70
像你管..最初他们显示图标屏幕而不是白色屏幕.并在2秒后显示主屏幕.
首先在res/drawable中创建一个XML drawable.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/gray"/>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher"/>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
接下来,您将把它设置为主题中的splash活动的背景.导航到styles.xml文件并为您的splash活动添加新主题
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
在新的SplashTheme中,将窗口背景属性设置为XML drawable.在AndroidManifest.xml中将其配置为splash活动的主题:
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
此链接提供您想要的内容.一步一步的程序. https://www.bignerdranch.com/blog/splash-screens-the-right-way/
更新:
这样layer-list可以更简单(它也接受中心徽标的矢量绘图,与<bitmap>标签不同):
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Background color -->
<item android:drawable="@color/gray"/>
<!-- Logo at the center of the screen -->
<item
android:drawable="@mipmap/ic_launcher"
android:gravity="center"/>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
Tar*_*run 66
在style.xml中创建一个样式,如下所示:
<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsTranslucent">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
并将其与您在AndroidManifest中的活动一起使用:
<activity android:name=".ActivitySplash" android:theme="@style/Theme.Transparent">
Run Code Online (Sandbox Code Playgroud)
你应该阅读Cyril Mottier撰写的这篇精彩帖子:Android App发布变得华丽
您需要自定义Themein style.xml,并避免在onCreateActionBar.setIcon/setTitle/etc中自定义.
另请参阅Google的性能提示文档.
使用Trace View和Hierarchy Viewer查看显示视图的时间:Android上的Android性能优化/性能调整
使用AsyncTask显示的一些看法.
这是我在应用示例应用中的AppTheme:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
如您所见,我有默认颜色,然后我添加了android:windowIsTranslucent并将其设置为true.
据我所知,作为Android开发人员,这是您需要设置的唯一事项,以便在应用程序的开头隐藏白屏.
| 归档时间: |
|
| 查看次数: |
92093 次 |
| 最近记录: |