Open GoogleCodeExporter opened 9 years ago
Hi,
I got the same problem on an Acer Iconia Tab with Android 4.0. Setting
android:hardwareAccelerated="false" solves the problem, but this is could be a
real solution.
Original comment by plin...@gmail.com
on 19 Oct 2012 at 7:44
This is a recognised problem by Google, the issue is that the HW Acceleration
causes the path to be rasterized to a 1x1 output, so you can't see it.
I have a workaround, which checks for HW acceleration and draws a line rather
than a path, it's not as pretty, but it's functional.
private void drawHand(Canvas canvas) {
if (handInitialized) {
float handAngle = degreeToAngle(handPosition);
canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.rotate(handAngle, 0.5f, 0.5f);
if(canvas.isHardwareAccelerated()) {
handPaint.setStrokeWidth(0.01f);
canvas.drawLine(0.5f, 0.7f,0.5f + 0.002f, 0.5f - 0.32f, handPaint);
} else {
canvas.drawPath(handPath, handPaint);
}
canvas.restore();
canvas.drawCircle(0.5f, 0.5f, 0.01f, handScrewPaint);
}
}
This is easy to debug using the emulator, just set the Emulator to "Use host
GPU" to see the behaviour change.
Original comment by doug.e...@gmail.com
on 25 Feb 2013 at 4:30
I've found a little bit nicer of a workaround. With the above method, the
needle is just a straight line. What you can do instead is disable hardware
acceleration on *only* the view you are needing the needle.
In code, once you've initialized the view:
private Gauge fuelGauge;
fuelGauge = (Gauge) getActivity().findViewById(R.id.fuelGauge);
Turn off hardware acceleration
fuelGauge.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
This leave global hardware acceleration on, but off on only the views needed.
Original comment by efrie...@gmail.com
on 13 Jun 2014 at 7:16
Original issue reported on code.google.com by
Evelyn...@gmail.com
on 24 Aug 2012 at 8:44