& Quot; Android uses Shape to draw dotted lines, and displays solid lines on mobile phones above 4.0 & quot; solution, androidshape

Source: Internet
Author: User

"Android uses Shape to draw dotted lines and display solid lines on mobile phones above 4.0" solution: androidshape

Problem description:

Use the following code to draw a dotted line:

<? Xml version = "1.0" encoding = "UTF-8"?> <Shape xmlns: android = "http://schemas.android.com/apk/res/android" android: shape = "line"> <! -- A dotted line is displayed. The broken line width is dashWith, and the gap width between broken lines is dashGap. When dashGap is set to 0dp, it is a solid line. --> <stroke android: dashGap = "3dp" android: dashWidth = "3dp" android: width = "1dp" android: color = "# dcdcdc"/> <! -- Height of the dotted line --> <size android: height = "1dp"/> </shape>

The code for referencing dotted lines in the layout file is as follows:

            <ImageView                android:layout_width="match_parent"                android:layout_height="2dip"                android:layout_margin="5dip"                android:background="@drawable/dotted_line" />

Note: dotted_line is the name of the shape file.


The image in the graphical layout view that comes with the adt is:



No problem, but it turns into a solid line when running on the mobile phone !!!, Yes !!!


Solution:

Find the androidmanifest. xml file of the project and add the property value (disable hardware acceleration) to the application tag, as shown below:



Then run the code again to solve the problem!

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.