<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Android實(shí)現(xiàn)登錄背景動(dòng)畫(huà)效果

          共 2153字,需瀏覽 5分鐘

           ·

          2021-04-08 10:23

          登錄QQ的時(shí)候,我們會(huì)看到在登錄界面的背景不是靜態(tài)的,而是一段動(dòng)畫(huà)效果,剛開(kāi)始覺(jué)得蠻好奇的,現(xiàn)在我們也來(lái)實(shí)現(xiàn)一下這種效果,實(shí)現(xiàn)起來(lái)還是挺簡(jiǎn)單的。


          效果圖:



          實(shí)現(xiàn)步驟:


          1、自定義CustomVideoView類(lèi)繼承VideoView
          2、實(shí)現(xiàn)xml布局文件
          3、將視頻文件放入raw目錄
          4、代碼實(shí)現(xiàn)動(dòng)畫(huà)效果


          實(shí)現(xiàn)過(guò)程:


          1、自定義CustomVideoView類(lèi)繼承VideoView

          package com.example.viewdemo;
          import android.content.Context;import android.media.MediaPlayer;import android.util.AttributeSet;import android.view.KeyEvent;import android.widget.VideoView;
          public class CustomVideoView extends VideoView {

          public CustomVideoView(Context context) { super(context); }
          public CustomVideoView(Context context, AttributeSet attrs) { super(context, attrs); }
          public CustomVideoView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); }
          @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { //我們重新計(jì)算高度 int width = getDefaultSize(0, widthMeasureSpec); int height = getDefaultSize(0, heightMeasureSpec); setMeasuredDimension(width, height); }
          @Override public void setOnPreparedListener(MediaPlayer.OnPreparedListener l) { super.setOnPreparedListener(l); }
          @Override public boolean onKeyDown(int keyCode, KeyEvent event) { return super.onKeyDown(keyCode, event);    }}


          2、實(shí)現(xiàn)xml布局文件

             <com.example.viewdemo.CustomVideoView        android:id="@+id/videoview"        android:layout_width="match_parent"        android:layout_height="match_parent" />


          3、將視頻文件放入raw目錄



          4、代碼實(shí)現(xiàn)動(dòng)畫(huà)效果

             //找VideoView控件        customVideoView = (CustomVideoView) findViewById(R.id.videoview);                //加載視頻文件        customVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.sport));
          //播放 customVideoView.start();
          //循環(huán)播放 customVideoView.setOnCompletionListener(newMediaPlayer.OnCompletionListener() {
          @Override publicvoid onCompletion (MediaPlayer mediaPlayer){ customVideoView.start(); } });


          需要源碼的童鞋在公眾號(hào)【龍旋】對(duì)話框回復(fù)關(guān)鍵字【背景動(dòng)畫(huà)】即可獲取哦.


          到這里就結(jié)束啦.


          瀏覽 75
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  无码一区二区四区 | 亚洲中文大香蕉 | 日韩午夜福利在线观看 | 午夜成人福利片 | 亚洲成人av一区二区三区 |