最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android中閃屏實現(xiàn)方法小結(jié)(普通閃屏、倒計時閃屏、倒計時+動畫閃屏)

 更新時間:2017年01月03日 15:55:13   作者:songyi160  
這篇文章主要介紹了Android中閃屏實現(xiàn)方法小結(jié)(普通閃屏、倒計時閃屏、倒計時+動畫閃屏),非常不錯,代碼簡單易懂,需要的朋友可以參考下

一、項目目錄結(jié)構(gòu)

二、activity_main.xml代碼

<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" 
  android:paddingBottom="@dimen/activity_vertical_margin" 
  android:paddingLeft="@dimen/activity_horizontal_margin" 
  android:paddingRight="@dimen/activity_horizontal_margin" 
  android:paddingTop="@dimen/activity_vertical_margin" 
  tools:context="com.zgs.SplashScreenByXml.MainActivity" > 
  <TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="主頁面" /> 
</RelativeLayout> 

三、activity_splashscreen.xml代碼

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  android:layout_width="match_parent" 
  android:layout_height="match_parent" 
  android:background="@drawable/splash" 
  android:orientation="vertical"  
  android:id="@+id/ll_splashActivity"> 
  <TextView 
    android:id="@+id/tv_countDown" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="end" 
    android:layout_marginEnd="20dp" 
    android:layout_marginTop="20dp" 
    android:textColor="@android:color/white" 
    android:textSize="20sp" /> 
</LinearLayout> 

四、SplashScreenActiviy.java代碼

package com.zgs.SplashScreenByXml; 
import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.os.CountDownTimer; 
import android.os.Handler; 
import android.view.View; 
import android.view.Window; 
import android.view.WindowManager; 
import android.view.animation.Animation; 
import android.view.animation.Animation.AnimationListener; 
import android.view.animation.TranslateAnimation; 
import android.widget.LinearLayout; 
import android.widget.TextView; 
import com.zgs.CommonlySplashScreen.R; 
public class SplashScreenActiviy extends Activity { 
  private TextView tv_countDown; 
  private LinearLayout ll_splashActivity; 
  @Override 
  protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    // 通過下面兩行代碼也可實現(xiàn)全屏無標(biāo)題欄顯示activity 
    // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    // this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    setContentView(R.layout.activity_splashscreen); 
    tv_countDown = (TextView) findViewById(R.id.tv_countDown); 
    ll_splashActivity = (LinearLayout) findViewById(R.id.ll_splashActivity); 
    /******************************************************************************** 
     * 
     * 普通閃屏實現(xiàn)方式 
     * 
     * ******************************************************************************/ 
    /*new Handler().postDelayed(new Runnable() { 
      @Override 
      public void run() { 
        Intent intent = new Intent(getApplicationContext(), MainActivity.class); 
        startActivity(intent); 
        finish(); 
      } 
    }, 1000*4);*/ 
    /******************************************************************************** 
     * 
     * 倒計時閃屏實現(xiàn)方式 
     * 
     * ******************************************************************************/ 
    /*MyCountDownTimer mc = new MyCountDownTimer(4000, 1000); 
    mc.start(); 
    new Handler().postDelayed(new Runnable() { 
      @Override 
      public void run() { 
        Intent intent = new Intent(getApplicationContext(), MainActivity.class); 
        startActivity(intent); 
        finish(); 
      } 
    }, 1000*4);*/ 
    /******************************************************************************** 
     * 
     * 倒計時+動畫閃屏實現(xiàn)方式 
     * 
     * ******************************************************************************/ 
    MyCountDownTimer mc = new MyCountDownTimer(4000, 1000);  
    mc.start(); 
    new Handler().postDelayed(new Runnable() { 
      @Override 
      public void run() { 
        //左移動畫 
        TranslateAnimation ta = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, -1, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0);  
        ta.setDuration(2000); //設(shè)置動畫執(zhí)行的時間 
        ta.setFillAfter(true);//當(dāng)動畫結(jié)束后 動畫停留在結(jié)束位置,然后等啟動主界面后將其銷毀 
        ll_splashActivity.startAnimation(ta); 
        ta.setAnimationListener(new AnimationListener() { 
          @Override 
          public void onAnimationStart(Animation arg0) { 
          } 
          @Override 
          public void onAnimationRepeat(Animation arg0) { 
          } 
          @Override 
          public void onAnimationEnd(Animation arg0) { 
            Intent intent = new Intent(getApplicationContext(), MainActivity.class); 
            startActivity(intent); 
            finish(); 
          } 
        }); 
      } 
    }, 1000*4); 
  } 
  class MyCountDownTimer extends CountDownTimer {  
    //millisInFuture:倒計時的總數(shù),單位毫秒 
    //例如 millisInFuture=1000;表示1秒 
    //countDownInterval:表示間隔多少毫秒,調(diào)用一次onTick方法() 
    //例如: countDownInterval =1000;表示每1000毫秒調(diào)用一次onTick() 
    public MyCountDownTimer(long millisInFuture, long countDownInterval) {  
      super(millisInFuture, countDownInterval);  
    }  
    public void onFinish() {  
      tv_countDown.setText("開始跳轉(zhuǎn)……"); 
    }  
    public void onTick(long millisUntilFinished) {  
      tv_countDown.setText("倒計時(" + millisUntilFinished / 1000 + ")"); 
    }  
  } 
} 

五、MainActivity.java代碼

package com.zgs.SplashScreenByXml; 
import android.app.Activity; 
import android.os.Bundle; 
import com.zgs.CommonlySplashScreen.R; 
public class MainActivity extends Activity { 
  @Override 
  protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    //為了讓閃屏結(jié)束后更自然的過度到主界面,去除主界面的啟動動畫,將下面函數(shù)的第一個參數(shù)設(shè)為0即可 
    overridePendingTransition(0, 0); 
  } 
} 

六、操作演示

以上所述是小編給大家介紹的Android中閃屏實現(xiàn)方法小結(jié)(普通閃屏、倒計時閃屏、倒計時+動畫閃屏),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

  • Android 雙進(jìn)程守護(hù)的實現(xiàn)代碼

    Android 雙進(jìn)程守護(hù)的實現(xiàn)代碼

    這篇文章主要介紹了Android 雙進(jìn)程守護(hù)的實現(xiàn)代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-08-08
  • Android拍攝照片后返回縮略圖的方法

    Android拍攝照片后返回縮略圖的方法

    這篇文章主要介紹了Android拍攝照片后返回縮略圖的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-09-09
  • 詳解Android 硬布局item的高級寫法

    詳解Android 硬布局item的高級寫法

    這篇文章主要介紹了詳解Android 硬布局item的高級寫法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • Android Studio IDE升級4.1以后Start Failed

    Android Studio IDE升級4.1以后Start Failed

    這篇文章主要介紹了Android Studio IDE升級4.1以后Start Failed,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-10-10
  • Android中startService基本使用方法概述

    Android中startService基本使用方法概述

    這篇文章主要介紹了Android中startService基本使用方法,詳細(xì)解釋了startService的基本使用概述及其生命周期,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2015-12-12
  • Android自定義邊緣凹凸的卡劵效果

    Android自定義邊緣凹凸的卡劵效果

    這篇文章主要介紹了Android自定義邊緣凹凸的卡劵效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • ViewPager判斷是向左劃還是右劃的實例

    ViewPager判斷是向左劃還是右劃的實例

    下面小編就為大家?guī)硪黄猇iewPager判斷是向左劃還是右劃的實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-04-04
  • Android采取BroadcastReceiver方式自動獲取驗證碼

    Android采取BroadcastReceiver方式自動獲取驗證碼

    這篇文章主要介紹了Android采取BroadcastReceiver方式自動獲取驗證碼,感興趣的小伙伴們可以參考一下
    2016-08-08
  • AndroidStudio實現(xiàn)微信界面設(shè)計

    AndroidStudio實現(xiàn)微信界面設(shè)計

    這篇文章帶你通過Androidstudio來實現(xiàn)微信的基礎(chǔ)界面,微信的界面主要包含了主頁、通訊錄、發(fā)現(xiàn)以及我的賬號功能區(qū),下文包含了整個開發(fā)過程,以及解決該問題的過程及思路并提供了源碼
    2021-10-10
  • Android SeekBar 自定義thumb旋轉(zhuǎn)動畫效果

    Android SeekBar 自定義thumb旋轉(zhuǎn)動畫效果

    某些音樂播放或者視頻播放的界面上,資源還在加載時,進(jìn)度條的原點(thumb)會顯示一個轉(zhuǎn)圈的效果。這篇文章主要介紹了Android SeekBar 自定義thumb thumb旋轉(zhuǎn)動畫效果,需要的朋友可以參考下
    2021-11-11

最新評論

肥东县| 禄丰县| 澎湖县| 嘉义县| 海盐县| 涪陵区| 黄陵县| 玉树县| 谢通门县| 太康县| 安西县| 板桥市| 庆阳市| 库尔勒市| 佛坪县| 灵山县| 嵩明县| 东乡县| 灌南县| 泰安市| 静乐县| 靖边县| 醴陵市| 德州市| 枣强县| 平南县| 阳泉市| 万州区| 抚顺县| 自贡市| 财经| 通山县| 固安县| 孟津县| 裕民县| 乐陵市| 德昌县| 车险| 布拖县| 古交市| 泰宁县|