I am using paint to draw a dashed line in android.
dashed.setPathEffect(new DashPathEffect(new float[] { 5, 5 }, 0));
During development, everything shows up fine in the Graphical Layout view. But when I plugin a real device, the device shows a solid line. At first I thought it was because my devices were all LG. Then I tested on a Samsung S4: same problem. Does anyone know how to fix this discrepancy? It makes no sense that the Graphical Layout is saying one thing and yet no actual device agrees with it. Any advice?
disable hardware acceleration might be not best way, try this from here :
Path baseline = new Path();
baseline.moveTo(0, 0);
baseline.lineTo(100, 0);
canvas.drawPath(baseline, paint);
See if turning off the hardware acceleration for the view helps:
@Override
public static void disableHardwareRendering(View v) {
v.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
From Android developers page on Hardware Acceleration:
Use a software layer type to force a view to be rendered in software. If a view that is hardware accelerated (for instance, if your whole application is hardware acclerated), is having rendering problems, this is an easy way to work around limitations of the hardware rendering pipeline.
Some more information about this issue on code.google: Link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With