Android項(xiàng)目實(shí)戰(zhàn)教程之高仿網(wǎng)易云音樂(lè)啟動(dòng)頁(yè)實(shí)例代碼
前言
本文主要給大家介紹了關(guān)于Android高仿網(wǎng)易云音樂(lè)啟動(dòng)頁(yè)的相關(guān)內(nèi)容,這一節(jié)我們來(lái)講解啟動(dòng)界面,效果如下:
首次創(chuàng)建一個(gè)SplashActivity用來(lái)做啟動(dòng)界面,因?yàn)閯?chuàng)建完項(xiàng)目默認(rèn)是MainActivity做主界面,所以需要去掉,將啟動(dòng)配置到同時(shí)去掉SplashActivity,并且去掉SplashActivity的標(biāo)題欄,同時(shí)還要設(shè)置為全屏。
Activity啟動(dòng)配置
在清單文件將啟動(dòng)配置剪貼到SplashActivity:
<activity android:name=".activity.SplashActivity" android:screenOrientation="portrait" android:theme="@style/NoActionBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
布局的話可以說(shuō)是很簡(jiǎn)單了,最外層使用RelativeLayout,頂部一個(gè)ImageView讓他在水平居中,具頂部一個(gè)距離,這個(gè)距離大家可以按照自己的業(yè)務(wù)需求調(diào)整,然后放入一個(gè)TextView讓他在水平居中,垂直方向和父布局的底部對(duì)齊,同時(shí)設(shè)置一個(gè)Margin,接著放一個(gè)ImageView用來(lái)顯示Logo,讓他在TextView的上方就行了:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.ixuea.android.courses.music.activity.SplashActivity"> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:scaleType="centerCrop" android:src="@drawable/splash_bg" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="130dp" android:src="@drawable/splash_banner" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/tv_copyright" android:layout_centerHorizontal="true" android:src="@drawable/splash_logo" /> <TextView android:id="@+id/tv_copyright" style="@style/CopyrightText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="20dp" android:layout_marginTop="10dp" android:text="Copyright © 2018 Ixuea. All Rights Reserved" /> </RelativeLayout>
Activity暫時(shí)沒(méi)什么太多的邏輯,只是創(chuàng)建一個(gè)Handler,然后延時(shí)3秒鐘進(jìn)行下一步,然后在next方法中判斷是否需要顯示引導(dǎo)界面,是否登錄等:
public class SplashActivity extends BaseCommonActivity { //這樣創(chuàng)建有內(nèi)存泄漏,在性能優(yōu)化我們具體講解 @SuppressLint("HandlerLeak") private Handler mHandler = new Handler() { @SuppressWarnings("unused") public void handleMessage(Message msg) { next(); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); //去除狀態(tài)欄 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_splash); } @Override protected void initDatas() { super.initDatas(); //延時(shí)3秒,在企業(yè)中通常會(huì)有很多邏輯處理,所以延時(shí)時(shí)間最好是用3-消耗的的時(shí)間 mHandler.postDelayed(new Runnable() { @Override public void run() { mHandler.sendEmptyMessage(-1); } }, 3000); } private void next() { if (isShowGuide()) { startActivityAfterFinishThis(GuideActivity.class); } else if (sp.isLogin()) { startActivityAfterFinishThis(MainActivity.class); } else { startActivityAfterFinishThis(LoginActivity.class); } } /** * 根據(jù)當(dāng)前版本號(hào)判斷是否需要引導(dǎo)頁(yè) * @return */ private boolean isShowGuide() { return sp.getBoolean(String.valueOf(PackageUtil.getVersionCode(getApplicationContext())),true); } }
當(dāng)前界面還可以增加倒計(jì)時(shí),廣告等內(nèi)容,這部分內(nèi)容我們?cè)诤竺嬖僦v解。
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,如果有疑問(wèn)大家可以留言交流,謝謝大家對(duì)腳本之家的支持。
- Android實(shí)現(xiàn)網(wǎng)易云推薦歌單界面
- Android實(shí)現(xiàn)網(wǎng)易云音樂(lè)的旋轉(zhuǎn)專輯View
- Android5.0以上實(shí)現(xiàn)全透明的狀態(tài)欄方法(仿網(wǎng)易云界面)
- Android仿網(wǎng)易云音樂(lè)播放界面
- 漂亮的Android音樂(lè)歌詞控件 仿網(wǎng)易云音樂(lè)滑動(dòng)效果
- Android控件RecyclerView實(shí)現(xiàn)混排效果仿網(wǎng)易云音樂(lè)
- Android實(shí)現(xiàn)網(wǎng)易云音樂(lè)高仿版流程
相關(guān)文章
Android實(shí)現(xiàn)多線程下載圖片的方法
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)多線程下載圖片的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09Android SQLite數(shù)據(jù)庫(kù)徹底掌握數(shù)據(jù)存儲(chǔ)
這篇文章主要介紹了 Android SQLite數(shù)據(jù)庫(kù)的相關(guān)資料,這里對(duì)Android SQLlite做了詳細(xì)介紹,需要的朋友可以參考下2016-10-10RecyclerView優(yōu)雅實(shí)現(xiàn)復(fù)雜列表布局
這篇文章主要為大家詳細(xì)介紹了RecyclerView優(yōu)雅實(shí)現(xiàn)復(fù)雜列表布局,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-11-11老生常談ProgressBar、ProgessDialog的用法
下面小編就為大家?guī)?lái)一篇老生常談ProgressBar、ProgessDialog的用法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-07-07Android ListView的item背景色設(shè)置和item點(diǎn)擊無(wú)響應(yīng)的解決方法
在Android開發(fā)中,listview控件是非常常用的控件,在大多數(shù)情況下,大家都會(huì)改掉listview的item默認(rèn)的外觀。2013-11-11Android開發(fā)之button事件監(jiān)聽簡(jiǎn)單實(shí)例
這篇文章主要介紹了Android開發(fā)之button事件監(jiān)聽實(shí)現(xiàn)方法,實(shí)例分析了事件監(jiān)聽的使用技巧與注意事項(xiàng),需要的朋友可以參考下2015-05-05