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