Android Learning problems encountered 1

Source: Internet
Author: User

1, problem: get ImageView's wide height in OnCreate, but all 0.

Cause:The OnCreate method executes, the defined control is measured, and the height or width of the control is obtained by View.getheight () within the OnCreate method, which is definitely 0, because it has not been measured. That means he doesn't know how tall he is, and when you go to get its size, it's definitely not going to work.

2. Problem: The custom control declares the definition failure in the XML file.

Cause: When declaring a control, if you want to use the control's properties, you must declare the following constructor defined.

Public MyView (context context, AttributeSet Attrs) {    Super (context, attrs);}

3. question: After the tween animation finishes, and set Translateanimation.setfillafter (True), how to hide the Viewimage control.

cause: The end point of the tweened animation is just the content of the control, and when we change the control's property visibility to invisibility, we can still see it at the end point of the animation.

Workaround: I set imageview.getbackground (). Setalpha (255) to hide the control by altering the contents of the control.

4. problem: When the tweened animation is set to Translateanimation.setfillafter (true), other animations of the control, such as frame animations, cannot be displayed.

cause: Because the tweened animation does not change the position of the control, setting Translateanimation.setfillafter (true) means that the last frame of the animation is displayed in the last position, if the control does not stop above its own position, The other animation effects are not displayed.

Workaround: After the tween animation finishes, set a looping animation at the end point.

Eg. Sets a translation animation at the end point loop in the end listener event of the motion tween.

Translateanimation.setanimationlistener (New Animation.animationlistener () {    @Override public    Void Onanimationstart (Animation Animation) {    }    @Override public    void Onanimationend (Animation Animation) {        //Set the animation that has been translating the end of the animation so that the wings have been flapping        Translateanimation aanimation = new Translateanimation (x, x, y, y);        Aanimation.setduration (10);//Set the duration of the animation        Aanimation.setrepeatcount ( -1);        Imageview.startanimation (aanimation);//Start animation    }    @Override public    void Onanimationrepeat (Animation Animation) {    }});

  

5. Problem: Brush blur effect setting is not valid.

Workaround: In Hardware acceleration is canceled in the Androidmanifest.xml.

Results :

Android Learning problems encountered 1

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: 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.