Android over-Drawing optimization

Source: Internet
Author: User

After opening the project

See Mainactivity and Activity_main.xml Find background colors in Activity_main.xml


Recall what the teacher said in the video, you can remove the window color, and then in the mainactivity in the OnCreate method to increase the GetWindow (). setbackgrounddrawable (NULL);



Open the display over paint area in the emulator and run the program



After discovering that the box behind the is Test text is over-drawn, activity_main.xml the area and finds nested multiple linearlayout with the same background color as its parent, the optimized code is as follows:



Click the Overdrawview button to enter overdrawviewactivity


Too much drawing, go into Overdrawview's OnDraw method to view


The more downward the drawing situation, the more serious it is that it can only be drawn to the beginning of the next rectangle.

Change the code to

After running, it is found that there are still over-drawn situations, after thinking will GetWindow (). setbackgrounddrawable (null); Add to Overdrawviewactivityon when you run the program in the Create method


When the above situation is over open Activity_busy_on_draw_view.xml discover nested multi-layer linearlayout run program click Busyondraw


There doesn't seem to be much of an over-drawn situation. The new Paint () of OnDraw in Busyondrawview is conveniently presented.

But nesting multi-layered linearlayout is not good. Similar effects can be implemented using a GridView, continue tomorrow!



Android over-Drawing optimization

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.