Android轻松实现高效的启动页
生活随笔
收集整理的這篇文章主要介紹了
Android轻松实现高效的启动页
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
??說到Android的啟動頁,Google以前是把它作為反面教程來講的,但是在材料設計規范里面,Google是支持開發者使用啟動頁的。這似乎好像有一點矛盾,但是新的建議和舊的建議都是站在一個角度來講的,最好不要浪費用戶的時間去打開沒有用的界面,然而好多應用一開始啟動都會花費一些時間,特別是第一次的時候,這個時候數據時第一次加載,大部分都會出現空白的頁面,所以為了用戶的友好體驗,建議使用啟動頁。第一次應該是最慢的,但是第一次緩存以后,再次打開應該是非常快的。
??找了一下網上的案例,大部分都會出現一些白屏或者黑屏的情況,然后就是設置一些透明的主題之類的。
??這里帶大家一起來實現一個簡單高效的啟動頁。
??首先我們來看一下效果:
首先在你的res/drawable文件夾下創建一個名為background_splash.的XML。
< ?xml version="1.0" encoding="utf-8"?> < layer-list xmlns:android="http://schemas.android.com/apk/res/android">< itemandroid:drawable="@color/gray"/>< item>< bitmapandroid:gravity="center"android:src="@drawable/girl"/>< /item> < /layer-list>打開你的styles.xml然后為你的Activity添加一個新的主題。
<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>然后在你的AndroidManifest.xml中配置一下就好了
< activityandroid: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>最后在你的SplashActivity里面加上如下代碼:
public class SplashActivity extends AppCompatActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);Intent intent = new Intent(this, MainActivity.class);startActivity(intent);finish();} }這樣我們就簡單的完成了啟動頁的制作。
轉載自:http://blog.csdn.net/u014727709/article/details/53762100
歡迎start,歡迎評論,歡迎指正
總結
以上是生活随笔為你收集整理的Android轻松实现高效的启动页的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2021-08-04 jQuery基础整
- 下一篇: Android中GPUImage的简单使