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

Android實現(xiàn)閃屏歡迎界面

 更新時間:2021年09月16日 10:57:30   作者:ami_daqi  
這篇文章主要介紹了Android實現(xiàn)閃屏歡迎界面的相關資料,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

閃屏:在打開App時,展示,持續(xù)數(shù)秒后,自動關閉,進入另外的一個界面,SplashActivity跳轉(zhuǎn)到MainActivity

Android中有三種實現(xiàn)方法

xml代碼:

<?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.example.administrator.test.SplashActivity">
  <ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/splash_iv"
    android:scaleType="fitXY"
    android:src="@mipmap/splash"/>

</RelativeLayout>

(1)利用Handler對象的postDelayed方法可以實現(xiàn),傳遞一個Runnable對象和一個需要延時的時間即可

 new Handler().postDelayed(new Runnable() {
      @Override
      public void run() {
        Intent intent=new Intent(SplashActivity.this,MainActivity.class);
        startActivity(intent);
        SplashActivity.this.finish();
      }
    },3000);

(2)使用動畫持續(xù)時間,動畫結(jié)束后進行跳轉(zhuǎn)

@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    iv =(ImageView)findViewById(R.id.splash_iv);
    iv.setImageResource(R.mipmap.splash);
    //設置透明度動畫從無到有
    AlphaAnimation alphaAnimation=new AlphaAnimation(0.0f,1.0f);
    //設置動畫持續(xù)時間
    alphaAnimation.setDuration(3000);
    //開始顯示動畫
    iv.startAnimation(alphaAnimation);
    //給動畫設置監(jiān)聽,在動畫結(jié)束的時候進行跳轉(zhuǎn)
    alphaAnimation.setAnimationListener(new Animation.AnimationListener() {
      @Override
      public void onAnimationStart(Animation animation) {
        //動畫開始時執(zhí)行
        Log.e("TAG", "onAnimationStart: " );
      }

      @Override
      public void onAnimationEnd(Animation animation) {
        //動畫結(jié)束時執(zhí)行
        Log.e("TAG", "onAnimationEnd: " );
        Intent intent=new Intent(SplashActivity.this,MainActivity.class);
        startActivity(intent);
        finish();
      }

      @Override
      public void onAnimationRepeat(Animation animation) {
        //動畫重復播放時執(zhí)行
        Log.e("TAG", "onAnimationRepeat: " );
      }
    });
}

(3)利用Timer定時器實現(xiàn),

 @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    iv =(ImageView)findViewById(R.id.splash_iv);
    iv.setImageResource(R.mipmap.splash);
    Timer timer=new Timer();
    timer.schedule(new TimerTask() {
      @Override
      public void run() {
        Intent intent=new Intent(SplashActivity.this,MainActivity.class);
        startActivity(intent);
        finish();
      }
    },3000);
  }

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • Android使用viewpager實現(xiàn)畫廊式效果

    Android使用viewpager實現(xiàn)畫廊式效果

    這篇文章主要為大家詳細介紹了Android使用viewpager實現(xiàn)畫廊式效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-08-08
  • Android自定義控件之圓形、圓角ImageView

    Android自定義控件之圓形、圓角ImageView

    這篇文章主要為大家詳細介紹了Android自定義控件之圓形、圓角ImageView的相關資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • Android中Notification的用法匯總

    Android中Notification的用法匯總

    這篇文章主要介紹了Android中Notification的用法匯總的相關資料,需要的朋友可以參考下
    2016-01-01
  • Android實現(xiàn)單頁面浮層可拖動view的示例代碼

    Android實現(xiàn)單頁面浮層可拖動view的示例代碼

    本篇文章主要介紹了Android實現(xiàn)單頁面浮層可拖動view的示例代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-10-10
  • Android 畫中畫模式的實現(xiàn)示例

    Android 畫中畫模式的實現(xiàn)示例

    這篇文章主要介紹了Android 畫中畫模式的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-12-12
  • Android Tab標簽的使用基礎

    Android Tab標簽的使用基礎

    Android程序中,Tab標簽窗口是一種常用的UI界面元素。這篇文章主要介紹了Android Tab標簽的使用基礎,有興趣的可以了解一下。
    2016-12-12
  • 解決Android studio模擬器啟動失敗的問題

    解決Android studio模擬器啟動失敗的問題

    這篇文章主要介紹了Android studio模擬器啟動失敗的問題及解決方法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-03-03
  • Android日期選擇控件使用詳解

    Android日期選擇控件使用詳解

    這篇文章主要為大家詳細介紹了Android日期選擇控件的使用,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-08-08
  • Android使用ViewPager完成app引導頁

    Android使用ViewPager完成app引導頁

    這篇文章主要為大家詳細介紹了Android使用ViewPager完成app引導頁,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-11-11
  • Android 異步加載圖片分析總結(jié)

    Android 異步加載圖片分析總結(jié)

    研究了android從網(wǎng)絡上異步加載圖像,現(xiàn)總結(jié)如下,感興趣的朋友可以了解下哈
    2013-06-06

最新評論

霸州市| 昌平区| 司法| 南安市| 慈利县| 东辽县| 灵武市| 尖扎县| 玉山县| 米林县| 长寿区| 汉阴县| 英山县| 合川市| 梁河县| 将乐县| 济源市| 海原县| 枣强县| 出国| 凤城市| 闵行区| 余江县| 靖江市| 遂平县| 合肥市| 万荣县| 北票市| 安泽县| 丰台区| 阜城县| 礼泉县| 老河口市| 宣威市| 陆丰市| 峡江县| 普兰店市| 冕宁县| 金溪县| 葵青区| 常宁市|