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

Android開發(fā)之splash界面下詳解及實例

 更新時間:2017年03月11日 09:28:57   投稿:lqh  
這篇文章主要介紹了 Android開發(fā)之splash界面下詳解及實例的相關(guān)資料,需要的朋友可以參考下

現(xiàn)在剛下載的很多APP應(yīng)用第一次打開都會在進入主界面之前有導(dǎo)航頁,用來展示公司logo,或者推廣自身這款A(yù)PP。先上效果圖:
這里寫圖片描述
這里寫圖片描述
這里寫圖片描述

首先解釋一下:支持進入首頁只能往右滑動,中間可以左右滑動,最后一張只能向前滑動,點擊立即體驗會進入主界面,點擊跳過也會進入到主界面。接下來上代碼。

1,在app/build.gradle中的閉包中加入:

compile 'cn.bingoogolapple:bga-banner:2.1.6@aar'
compile 'com.android.support:support-v4:24.1.0'

2,布局文件:activity_splash.xml。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/activity_splash"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="com.gyq.cloudreader.SplashActivity">

  <cn.bingoogolapple.bgabanner.BGAGuideLinkageLayout style="@style/MatchMatch">

    <cn.bingoogolapple.bgabanner.BGABanner
      android:id="@+id/banner_guide_background"
      style="@style/MatchMatch"
      app:banner_pageChangeDuration="1000"
      app:banner_pointAutoPlayAble="false"
      app:banner_pointContainerBackground="@android:color/transparent"
      app:banner_pointDrawable="@drawable/bga_banner_selector_point_hollow"
      app:banner_pointTopBottomMargin="15dp"
      app:banner_transitionEffect="fade"/>

    <cn.bingoogolapple.bgabanner.BGABanner
      android:id="@+id/banner_guide_foreground"
      style="@style/MatchMatch"
      app:banner_pageChangeDuration="1000"
      app:banner_pointAutoPlayAble="false"
      app:banner_pointContainerBackground="@android:color/transparent"
      app:banner_pointDrawable="@drawable/bga_banner_selector_point_hollow"
      app:banner_pointTopBottomMargin="15dp"
      app:banner_transitionEffect="alpha"/>
  </cn.bingoogolapple.bgabanner.BGAGuideLinkageLayout>

  <TextView
    android:id="@+id/tv_guide_skip"
    style="@style/WrapWrap"
    android:layout_alignParentRight="true"
    android:layout_marginRight="8dp"
    android:layout_marginTop="8dp"
    android:clickable="true"
    android:padding="4dp"
    android:text="跳過 >"
    android:textColor="@android:color/white"
    android:textSize="16sp"/>

  <Button
    android:id="@+id/btn_guide_enter"
    style="@style/WrapWrap"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="60dp"
    android:background="@drawable/selector_btn_test"
    android:padding="10dp"
    android:text="立即體驗"
    android:textColor="@android:color/white"
    android:textSize="20sp"
    android:visibility="gone"
    tools:visibility="visible"/>

</RelativeLayout>

3,邏輯代碼,SplashActivity.java

package com.gyq.cloudreader;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import cn.bingoogolapple.bgabanner.BGABanner;

/**
 * 引導(dǎo)界面
 */
public class SplashActivity extends AppCompatActivity {
  private BGABanner mBackgroundBanner;
  private BGABanner mForegroundBanner;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    initView();

    initListener();

    processLogic();

  }

  private void initView() {
    mBackgroundBanner = (BGABanner)findViewById(R.id.banner_guide_background);
    mForegroundBanner = (BGABanner)findViewById(R.id.banner_guide_foreground);
  }

  private void initListener() {
    mForegroundBanner.setEnterSkipViewIdAndDelegate(R.id.btn_guide_enter, R.id.tv_guide_skip, new BGABanner.GuideDelegate() {
      @Override
      public void onClickEnterOrSkip() {
        startActivity(new Intent(SplashActivity.this, MainActivity.class));
        finish();
      }
    });

  }

  private void processLogic() {
    //設(shè)置數(shù)據(jù)源
    mBackgroundBanner.setData(R.drawable.uoko_guide_background_1,R.drawable.uoko_guide_background_2,R.drawable.uoko_guide_background_3);
    mForegroundBanner.setData(R.drawable.uoko_guide_foreground_1,R.drawable.uoko_guide_foreground_2,R.drawable.uoko_guide_foreground_3);
  }

  @Override
  protected void onResume() {
    super.onResume();

    // 如果開發(fā)者的引導(dǎo)頁主題是透明的,需要在界面可見時給背景 Banner 設(shè)置一個白色背景,避免滑動過程中兩個 Banner 都設(shè)置透明度后能看到 Launcher
    mBackgroundBanner.setBackgroundResource(android.R.color.white);
  }
}

小結(jié):記得以前寫一個這樣的引導(dǎo)頁,還需要自己手寫半天,現(xiàn)在有開源啦!看上面的代碼我想你應(yīng)該已經(jīng)知道了這個就是用的BGABanner來實現(xiàn)的。不過還有點小細節(jié)。

1,布局文件中的style=”@style/WrapWrap”,我們需要在values文件夾下新建一個styles_base.xml。

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

  <style name="WrapMatch">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">match_parent</item>
  </style>

  <style name="MatchWrap">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>
  </style>

  <style name="WrapWrap">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
  </style>

  <style name="MatchMatch">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">match_parent</item>
  </style>

  <style name="MatchAuto">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_weight">1</item>
    <item name="android:layout_height">0dp</item>
  </style>

  <style name="AutoMatch">
    <item name="android:layout_width">0dp</item>
    <item name="android:layout_weight">1</item>
    <item name="android:layout_height">match_parent</item>
  </style>

  <style name="WrapAuto">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_weight">1</item>
    <item name="android:layout_height">0dp</item>
  </style>

  <style name="AutoWrap">
    <item name="android:layout_width">0dp</item>
    <item name="android:layout_weight">1</item>
    <item name="android:layout_height">wrap_content</item>
  </style>

  <style name="WrapMatch.Vertical">
    <item name="android:orientation">vertical</item>
  </style>

  <style name="WrapMatch.Horizontal">
    <item name="android:orientation">horizontal</item>
  </style>

  <style name="MatchWrap.Vertical">
    <item name="android:orientation">vertical</item>
  </style>

  <style name="MatchWrap.Horizontal">
    <item name="android:orientation">horizontal</item>
  </style>

  <style name="WrapWrap.Vertical">
    <item name="android:orientation">vertical</item>
  </style>

  <style name="WrapWrap.Horizontal">
    <item name="android:orientation">horizontal</item>
  </style>

  <style name="MatchMatch.Vertical">
    <item name="android:orientation">vertical</item>
  </style>

  <style name="MatchMatch.Horizontal">
    <item name="android:orientation">horizontal</item>
  </style>

  <style name="MatchAuto.Vertical">
    <item name="android:orientation">vertical</item>
  </style>

  <style name="MatchAuto.Horizontal">
    <item name="android:orientation">horizontal</item>
  </style>

  <style name="AutoMatch.Vertical">
    <item name="android:orientation">vertical</item>
  </style>

  <style name="AutoMatch.Horizontal">
    <item name="android:orientation">horizontal</item>
  </style>

  <style name="WrapAuto.Vertical">
    <item name="android:orientation">vertical</item>
  </style>

  <style name="WrapAuto.Horizontal">
    <item name="android:orientation">horizontal</item>
  </style>

  <style name="AutoWrap.Vertical">
    <item name="android:orientation">vertical</item>
  </style>

  <style name="AutoWrap.Horizontal">
    <item name="android:orientation">horizontal</item>
  </style>

  <style name="MatchOne">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">1px</item>
  </style>

  <style name="OneMatch">
    <item name="android:layout_width">1px</item>
    <item name="android:layout_height">match_parent</item>
  </style>
</resources>

還有styles.xml文件中添加如下代碼,這樣可以整個屏幕顯示:

<resources>

  <!-- Base application theme. -->
  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
  </style>

  <!--避免第一次進來白屏或黑屏-->
  <style name="AppTheme.Splash">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
  </style>

</resources>

最后清單文件,注冊SplashActivity是寫如下代碼。

<activity android:name=".SplashActivity"
      android:label="@string/app_name"
      android:screenOrientation="portrait"
      android:theme="@style/AppTheme.Splash">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

  • Android 判斷網(wǎng)絡(luò)狀態(tài)及開啟網(wǎng)路

    Android 判斷網(wǎng)絡(luò)狀態(tài)及開啟網(wǎng)路

    這篇文章主要介紹了Android 判斷網(wǎng)絡(luò)狀態(tài)及開啟網(wǎng)路的相關(guān)資料,在開發(fā)網(wǎng)路狀態(tài)的時候需要先判斷是否開啟之后在提示用戶進行開啟操作,需要的朋友可以參考下
    2017-08-08
  • Android模仿To圈兒個人資料界面層疊淡入淡出顯示效果

    Android模仿To圈兒個人資料界面層疊淡入淡出顯示效果

    這篇文章主要介紹了Android模仿To圈兒個人資料界面層疊淡入淡出顯示效果的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2016-07-07
  • android設(shè)備間實現(xiàn)無線投屏的示例代碼

    android設(shè)備間實現(xiàn)無線投屏的示例代碼

    Android提供了MediaProjection來實現(xiàn)錄屏,通過MediaProjection可以獲取當(dāng)前屏幕的視頻流,而視頻流需要通過編解碼來壓縮進行傳輸,通過MediaCodec可實現(xiàn)視頻的編碼和解碼,這篇文章主要介紹了android設(shè)備間實現(xiàn)無線投屏,需要的朋友可以參考下
    2022-06-06
  • 點擊微信內(nèi)網(wǎng)頁a標(biāo)簽直接跳轉(zhuǎn)打開淘寶APP的方法實例

    點擊微信內(nèi)網(wǎng)頁a標(biāo)簽直接跳轉(zhuǎn)打開淘寶APP的方法實例

    這篇文章主要給大家介紹了關(guān)于如何實現(xiàn)點擊微信內(nèi)網(wǎng)頁a標(biāo)簽直接跳轉(zhuǎn)打開淘寶APP的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起看看吧。
    2017-11-11
  • Android實現(xiàn)listview滑動時漸隱漸現(xiàn)頂部欄實例代碼

    Android實現(xiàn)listview滑動時漸隱漸現(xiàn)頂部欄實例代碼

    android中實現(xiàn)listview滑動時漸隱漸現(xiàn)頂部欄只是在獲取listview的滑動距離上可能沒法直接獲取,需要動態(tài)的去計算。感興趣的朋友一起看看吧
    2016-10-10
  • Android實現(xiàn)斷點續(xù)傳功能

    Android實現(xiàn)斷點續(xù)傳功能

    這篇文章主要為大家詳細介紹了Android實現(xiàn)斷點續(xù)傳功能,能在上次的斷點處繼續(xù)上傳,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • Android編程設(shè)計模式之原型模式實例詳解

    Android編程設(shè)計模式之原型模式實例詳解

    這篇文章主要介紹了Android編程設(shè)計模式之原型模式,結(jié)合實例形式詳細分析了Android設(shè)計模式之原型模式的概念、原理、定義、使用方法及相關(guān)注意事項,需要的朋友可以參考下
    2017-12-12
  • RxJava構(gòu)建流基本原理示例解析

    RxJava構(gòu)建流基本原理示例解析

    這篇文章主要為大家介紹了RxJava構(gòu)建流基本原理示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-12-12
  • Android實現(xiàn)Ant Design 自定義表單組件

    Android實現(xiàn)Ant Design 自定義表單組件

    Ant Design 組件提供了Input,InputNumber,Radio,Select,uplod等表單組件,下面通過本文給大家詳細介紹Android實現(xiàn)Ant Design 自定義表單組件,需要的的朋友參考下吧
    2017-06-06
  • Android SeekBar在刷新使用中需要注意的問題

    Android SeekBar在刷新使用中需要注意的問題

    SeekBar在刷新使用中需要注意的問題:在使用SeekBar的過程中需要注意刷新頻率,避免頻繁刷新造成的性能問題;同時,需要對SeekBar的監(jiān)聽事件進行適當(dāng)?shù)膬?yōu)化,減少回調(diào)次數(shù),提高響應(yīng)速度
    2023-05-05

最新評論