Android dashed drawing, graphics hardware acceleration

Source: Internet
Author: User
Tags dashed line

Problem:

As for how to draw the dotted line is not much to say, online everywhere, talk about the development of the problems encountered:

1. starting with Android3.0, the Android 2D drawing process is designed to better support hardware acceleration. Hardware acceleration is used when you use the GPU's view to draw on the canvas. But then when we define the shape to draw the dashed line, we find that the drawing is not a dashed line but an implementation.

At that time the solution was searched, not hesitate to mark it directly on the application attribute

<applicationandroid:hardwareaccelerated= "true" ...>

The problem is that when the hardware acceleration is turned off, the ListView slides on the splash screen. Obviously we can't application the level to turn off hardware acceleration because it might affect the effect of other pages.

Workaround:

Activity level

If your application cannot be application the application level is performing well, you can use the activity for separate control. To start or disable hardware acceleration for a activity , you can use activity Android:hardwareaccelerated the property. One of the following columns makes the entire application enable hardware acceleration, but for a activity disables the use of hardware acceleration.

<application android:hardwareaccelerated= "true" >    <activity .../>   <activity android: Hardwareaccelerated= "false"/></application>




View level

We can disable hardware acceleration for individual View at run time phase. We can use the following code:

Myview.setlayertype (view.layer_type_software, NULL);

Note: Hardware acceleration at the view level is not possible at this stage.


Android dashed drawing, graphics hardware acceleration

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.