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

Android Studio實(shí)現(xiàn)幀動(dòng)畫

 更新時(shí)間:2021年11月14日 15:46:32   作者:G.O.Y  
這篇文章主要為大家詳細(xì)介紹了Android Studio實(shí)現(xiàn)幀動(dòng)畫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android Studio實(shí)現(xiàn)幀動(dòng)畫的具體代碼,供大家參考,具體內(nèi)容如下

按一定的順序播放靜態(tài)的圖片

1、幾張聯(lián)系的圖片

2、一個(gè)圖片資源管理布局文件:cartoon_source.xml

3、一個(gè)主要的布局文件:cartoon.xml

4、main.java文件

cartoon_source.xml

<?xml version="1.0" encoding="utf-8"?>
//幀動(dòng)畫資源列表控件
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
  //第一個(gè)是圖片資源的地址;第二參數(shù)是這個(gè)圖片播放的事件:120ms;
    <item android:drawable="@drawable/boy_0" android:duration="120"/>
    <item android:drawable="@drawable/boy_1" android:duration="120"/>
    <item android:drawable="@drawable/boy_2" android:duration="120"/>
    <item android:drawable="@drawable/boy_3" android:duration="120"/>
    <item android:drawable="@drawable/boy_4" android:duration="120"/>
    <item android:drawable="@drawable/boy_5" android:duration="120"/>
    <item android:drawable="@drawable/boy_6" android:duration="120"/>
    <item android:drawable="@drawable/boy_7" android:duration="120"/>
</animation-list>

cartoon.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:id="@+id/boy"
    android:background="@drawable/cartoon"(背景為資源整合布局文件)
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"/>

main.java

package com.example.imageview;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.NotificationCompat;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.nio.channels.Channel;
import java.util.ArrayList;
import java.util.List;

public class MainActivity<i> extends AppCompatActivity {
    /*
    private static final String TAG = "leo";
    private NotificationManager manager;
    private Notification notification;
    private PopupWindow popupWindow;
    //創(chuàng)建一個(gè)數(shù)組,內(nèi)部元素為Bean類型;
    private List<Bean> data = new ArrayList<>();
     */
    private boolean flag = true;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cartoon_boy);
        //獲得布局
        RelativeLayout relativeLayout = findViewById(R.id.boy);
        //從布局中獲得背景
        AnimationDrawable anim = (AnimationDrawable)relativeLayout.getBackground();
        //設(shè)置點(diǎn)擊監(jiān)聽
        relativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (flag){
                    anim.start();
                    flag = false;
                }
                else{
                    anim.stop();
                    flag = true;
                }
            }
        });
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android實(shí)現(xiàn)系統(tǒng)狀態(tài)欄的隱藏和顯示功能

    Android實(shí)現(xiàn)系統(tǒng)狀態(tài)欄的隱藏和顯示功能

    這篇文章主要介紹了Android實(shí)現(xiàn)系統(tǒng)狀態(tài)欄的隱藏和顯示功能,文中還給大家?guī)?lái)四種方法,大家可以根據(jù)自己需要參考下
    2018-07-07
  • Android解析XML文件升級(jí)APK的方法

    Android解析XML文件升級(jí)APK的方法

    這篇文章主要介紹了Android解析XML文件升級(jí)APK的方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-07-07
  • Android開發(fā)常見錯(cuò)誤小結(jié)

    Android開發(fā)常見錯(cuò)誤小結(jié)

    這篇文章主要介紹了Android開發(fā)常見錯(cuò)誤,實(shí)例分析了常見的Android開發(fā)中遇到的錯(cuò)誤,對(duì)Android開發(fā)有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-05-05
  • Android自定義控件ListView下拉刷新的代碼

    Android自定義控件ListView下拉刷新的代碼

    今天小編就為大家分享一篇關(guān)于Android自定義控件ListView下拉刷新的代碼,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2018-12-12
  • Kotlin原理詳析之拓展函數(shù)

    Kotlin原理詳析之拓展函數(shù)

    kotlin中的擴(kuò)展函數(shù),實(shí)際上是在自己的類中添加了一個(gè)static final方法,將需要擴(kuò)展的類,在使用的時(shí)候作為第一個(gè)參數(shù)傳入方法中,然后使用,這篇文章主要給大家介紹了關(guān)于Kotlin原理詳析之拓展函數(shù)的相關(guān)資料,需要的朋友可以參考下
    2022-01-01
  • Android仿微信聯(lián)系人字母排序效果

    Android仿微信聯(lián)系人字母排序效果

    大家使用到的聯(lián)系人界面,幾乎都是按照字母排序,如何實(shí)現(xiàn)聯(lián)系人按字母排序?下面就為大家詳解介紹了Android仿微信聯(lián)系人按字母排序的實(shí)現(xiàn)方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • Android自定義實(shí)現(xiàn)轉(zhuǎn)盤菜單

    Android自定義實(shí)現(xiàn)轉(zhuǎn)盤菜單

    旋轉(zhuǎn)菜單是一種占用空間較大,實(shí)用性稍弱的UI,本文主要為大家詳細(xì)介紹了Android如何自定義實(shí)現(xiàn)轉(zhuǎn)盤菜單,文中的示例代碼講解詳細(xì),有需要的小伙伴可以參考下
    2023-12-12
  • Flutter開發(fā)之支持放大鏡的輸入框功能實(shí)現(xiàn)

    Flutter開發(fā)之支持放大鏡的輸入框功能實(shí)現(xiàn)

    在Flutter開發(fā)時(shí),有時(shí)為了優(yōu)化用戶輸入體驗(yàn),往往會(huì)需要輸入框支持在移動(dòng)光標(biāo)過(guò)程中可以出現(xiàn)放大鏡功能。本文將為大家介紹實(shí)現(xiàn)的方法,需要的可以參考一下
    2022-02-02
  • Android DataBinding單向數(shù)據(jù)綁定深入探究

    Android DataBinding單向數(shù)據(jù)綁定深入探究

    看了谷歌官方文章確實(shí)寫的太簡(jiǎn)略了,甚至看完之后有很多地方還不知道怎么回事兒或者怎么用,那么接下來(lái)我將通過(guò)文章全面介紹一下DataBinding單向數(shù)據(jù)綁定
    2022-11-11
  • Android使用OkHttp上傳圖片的實(shí)例代碼

    Android使用OkHttp上傳圖片的實(shí)例代碼

    本篇文章主要介紹了Android使用OkHttp上傳圖片的實(shí)例代碼,這里整理了相關(guān)的代碼,有興趣的可以了解一下
    2017-07-07

最新評(píng)論

民丰县| 博白县| 拜城县| 临夏县| 延津县| 松原市| 铁岭市| 翼城县| 满洲里市| 定西市| 濉溪县| 广宗县| 日照市| 申扎县| 葵青区| 萝北县| 维西| 萨嘎县| 临朐县| 鸡泽县| 云南省| 韩城市| 庆云县| 凤山市| 定结县| 普兰店市| 乐都县| 和硕县| 延吉市| 兴仁县| 承德县| 郸城县| 巫山县| 四子王旗| 黄平县| 杂多县| 昌平区| 龙江县| 涿鹿县| 曲阳县| 舟曲县|