欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android項(xiàng)目實(shí)戰(zhàn)教程之高仿網(wǎng)易云音樂(lè)啟動(dòng)頁(yè)實(shí)例代碼

 更新時(shí)間:2018年09月12日 15:16:32   作者:愛學(xué)啊  
這篇文章主要給大家介紹了關(guān)于Android項(xiàng)目實(shí)戰(zhàn)教程之高仿網(wǎng)易云音樂(lè)啟動(dòng)頁(yè)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

前言

本文主要給大家介紹了關(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ì)腳本之家的支持。

相關(guān)文章

最新評(píng)論