Achieve image fade-in effect

Source: Internet
Author: User
<Relativelayout xmlns: Android = "http://schemas.android.com/apk/res/android" xmlns: Tools = "http://schemas.android.com/tools" Android: layout_width = "fill_parent" Android: layout_height = "match_parent" Android: background = "@ drawable/bg_ling"> <imageview Android: Id = "@ + ID/image" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: src = "@ drawable/welcome"/> <textview Android: Id = "@ + ID/compete" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_centerhorizontal = "true" Android: layout_centervertical = "true" Android: text = "@ string/hello_world"/> <progressbar Android: Id = "@ + ID/prograssbar" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" style = "@ Android: ATTR/progressbarstyle" Android: visibility = "gone" Android: layout_above = "@ ID/compete" Android: layout_centerhorizontal = "true"/> </relativelayout>

Package CN. BZU. alphaanimation; import android. OS. bundle; import android. OS. handler; import android. app. activity; import android. content. intent; import android. view. menu; import android. view. view; import android. view. animation. alphaanimation; import android. widget. imageview; import android. widget. progressbar; public class alphaanimationactivity extends activity {private progressbar; private imageview image; @ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. activity_alpha_animation); progressbar = (progressbar) This. findviewbyid (R. id. prograssbar); image = (imageview) This. findviewbyid (R. id. image); progressbar. setvisibility (view. visible); // create an animation object for the fade-in effect: alphaanimation animation = new alphaanimation (0.0f, 0.1f); animation. setduration (1000); animation. setstartoffset (500); image. setanimation (animation); new handler (). postdelayed (New runnable () {// create a handler to implement the demo jump @ overridepublic void run () {intent = new intent (); intent. setclass (alphaanimationactivity. this, mainactivity. class); startactivity (intent); }}, 1500) ;}@ override public Boolean oncreateoptionsmenu (menu) {getmenuinflater (). inflate (R. menu. activity_alpha_animation, menu); Return true ;}}

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: info-contact@alibabacloud.com 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.