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

Android Studio實現(xiàn)幀動畫

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

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

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

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

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

3、一個主要的布局文件:cartoon.xml

4、main.java文件

cartoon_source.xml

<?xml version="1.0" encoding="utf-8"?>
//幀動畫資源列表控件
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
  //第一個是圖片資源的地址;第二參數(shù)是這個圖片播放的事件: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)建一個數(shù)組,內部元素為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();
        //設置點擊監(jiān)聽
        relativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (flag){
                    anim.start();
                    flag = false;
                }
                else{
                    anim.stop();
                    flag = true;
                }
            }
        });
}

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

相關文章

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

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

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

    Android解析XML文件升級APK的方法

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

    Android開發(fā)常見錯誤小結

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

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

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

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

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

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

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

    Android自定義實現(xiàn)轉盤菜單

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

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

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

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

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

    Android使用OkHttp上傳圖片的實例代碼

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

最新評論

平南县| 财经| 监利县| 常熟市| 信丰县| 常州市| 仲巴县| 江华| 南郑县| 钟山县| 湖北省| 木兰县| 房山区| 潞西市| 德州市| 平湖市| 行唐县| 镇巴县| 高州市| 潞城市| 杨浦区| 拉萨市| 什邡市| 桃源县| 教育| 合山市| 大安市| 涞水县| 广平县| 周至县| 抚松县| 子洲县| 汶川县| 文安县| 玉林市| 固安县| 嘉荫县| 南郑县| 乌兰浩特市| 尖扎县| 全州县|