In accelerazione hardware personalizzato View
aggiunti in ScrollView
o ListView
entrambi i seguenti frammenti di codice produce lo stesso risultato: (si prega di ignorare le migliori pratiche per un secondo)strano comportamento di `drawTextOnPath()` con accelration hardware
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// centering stuff
float centerX = getWidth()/2f;
float centerY = getHeight()/2f;
float size = 80;
float halfSize = size/2f;
float left = centerX - halfSize;
float top = centerY - halfSize;
RectF oval = new RectF(left, top, left + size, top + size);
Path path = new Path();
path.addArc(oval, 160, 359);
Paint paint = new Paint();
paint.setTextSize(30);
paint.setStyle(Style.STROKE);
canvas.drawTextOnPath("Hello world", path, 0, 0, paint); //<--- line A
canvas.drawCircle(centerX, centerY, 10, paint); //<--- line B
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// centering stuff
float centerX = getWidth()/2f;
float centerY = getHeight()/2f;
float size = 80;
float halfSize = size/2f;
float left = centerX - halfSize;
float top = centerY - halfSize;
RectF oval = new RectF(left, top, left + size, top + size);
Path path = new Path();
path.addArc(oval, 160, 359);
Paint paint = new Paint();
paint.setTextSize(30);
paint.setStyle(Style.STROKE);
canvas.drawCircle(centerX, centerY, 10, paint); //<--- line B
canvas.drawTextOnPath("Hello world", path, 0, 0, paint); //<--- line A
}
stesso risultato:
Ma con frammento di codice in seguito, non appena si scorrere la ScrollView
(ho invisibile manichino View
di seguito in modo da poter scorrere) e HelloWorld tocca ActionBar
, qualcosa di molto interessante accade e si vede qualcosa che intelligent humankind used to see in old Windows OS.
So drawTextOnPath()
non è supportato in modalità accelration hardware, ma allora perché funziona se lo si chiama per primo?