Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize frame Animation with Android Studio

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how Android Studio realizes frame animation". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "how Android Studio realizes frame animation" together!

Play static pictures in a certain order

1. A few pictures of contact

2. A picture resource management layout file: cartoon_source.xml

3. A main layout file: cartoon.xml

4. Main.java file

cartoon_source.xml

//Frame animation resource list control//The first parameter is the address of the image resource; the second parameter is the event played by this image: 120ms;

cartoon.xml

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 extends AppCompatActivity { /* private static final String TAG = "leo"; private NotificationManager manager; private Notification notification; private PopupWindow popupWindow; //Create an array with Bean elements inside; private List data = new ArrayList(); */ private boolean flag = true; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.cartoon_boy); //Get Layout RelativeLayout relativeLayout = findViewById(R.id.boy); //Get background from layout AnimationDrawable anim = (AnimationDrawable)relativeLayout.getBackground(); //Settings Click to monitor relativeLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (flag){ anim.start(); flag = false; } else{ anim.stop(); flag = true; } } });} Thank you for reading, the above is "Android Studio how to achieve frame animation" content, after learning this article, I believe that everyone on Android Studio how to achieve frame animation this problem has a deeper understanding, the specific use of the situation also needs to be verified. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report