Android software startup animation and animation after the end of the implementation of the jump _android

Source: Internet
Author: User

This article describes the Android software startup animation and animation after the end of the implementation of the jump. Share to everyone for your reference, specific as follows:

I wrote a small program, software startup, first show a few pictures, every 3 seconds to display a picture, show the end of the jump to the home page

1. The picture Carousel uses gallery, the usage is very simple

Galleryadapter adapter = new Galleryadapter (this, mIds);
Mgallery.setadapter (adapter);

Galleryadapter is a custom adapter

public class Galleryadapter extends Baseadapter {private context mcontext;
  private int mimageheight;
  Private int[] MIds;
   Public Galleryadapter (context context, int[] ids) {This.mcontext = context;
   This.mids = IDs;
  Init ();
  private void Init () {mimageheight = Px2dip (Mcontext, Getscreenheight (mainactivity.this));
  @Override public int GetCount () {return mids.length;
  @Override public Object getitem (int position) {return position;
  @Override public long getitemid (int position) {return position;  @Override public View getview (int position, View Convertview, ViewGroup parent) {Final ImageView ImageView = new
   ImageView (Mcontext);
    if (position < mids.length) {int imageid = mids[position]; Imageview.setscaletype (ImageView.ScaleType.CENTER_CROP)//Set picture centered Imageview.setlayoutparams (new
    Gallery.layoutparams (Gallery.LayoutParams.FILL_PARENT, mimageheight)); Bitmap Bitmap = Readbitmap (Mcontext, IMAGeid////////////////////////////////
  Overridependingtransition (r.anim.push_in, r.anim.push_out);//Picture Toggle Animation} return ImageView;


2. Set picture switching time using timer timer

Timer timer = new timer ();
Timer.schedule (Task, 3000, 3000); Toggle a picture every 3 seconds
private timertask task = new TimerTask () {@Override public
  void run () {message Message
   = new Message ();
   message.what = 0;
   index = Mgallery.getselecteditemposition ();
   Handler.sendmessage (message);
   if (index = = mids.length-1) {
    this.cancel ();
    MainActivity.this.finish ();
    Intent Intent = new Intent (mainactivity.this, test.class);
    StartActivity (intent);
You cannot update the UI directly in a task, so send a message to the main thread with Handler
private Handler Handler = new Handler () {
  @Override public
  Void Handlemessage (Message msg) {
   super.handlemessage (msg);
   Switch (msg.what) {case
    mgallery.setselection (index);
   Default: Break;}}

3. Read local resource picture

public static Bitmap Readbitmap (context context, int resid) {
  bitmapfactory.options opt = new Bitmapfactory.options () ;
  Opt.inpreferredconfig = Bitmap.Config.RGB_565;
  Opt.inpurgeable = true;
  Opt.ininputshareable = true;
  Get resource picture
  InputStream is = Context.getresources (). Openrawresource (RESID);
  Return Bitmapfactory.decodestream (IS, null, opt);

Full instance code code click here to download the site.

I hope this article will help you with the Android program.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.