mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-05-08 03:28:07 +03:00
make android.text.Layout.draw() compatible custom Canvas classes
TextAndroidCanvas is a proxy canvas class which prevents us from accessing the GtkSnapshot of the real canvas. To solve this problem, we call Canvas.drawText() for each line.
This commit is contained in:
parent
4bb5dfd86e
commit
24f839f556
7 changed files with 44 additions and 4 deletions
|
@ -2,6 +2,7 @@ package android.text;
|
|||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.GskCanvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
|
||||
public class Layout {
|
||||
|
@ -59,8 +60,6 @@ public class Layout {
|
|||
}
|
||||
|
||||
public int getHeight() {
|
||||
System.out.println("height = " + native_get_height(layout));
|
||||
System.out.println("should be " + ((int)(paint.measureText("_") * 3)));
|
||||
return native_get_height(layout);
|
||||
}
|
||||
|
||||
|
@ -68,7 +67,7 @@ public class Layout {
|
|||
if (canvas instanceof GskCanvas)
|
||||
native_draw(layout, ((GskCanvas)canvas).snapshot, paint.paint);
|
||||
else
|
||||
canvas.drawText(text.toString(), 0, 0, paint);
|
||||
native_draw_custom_canvas(layout, canvas, paint);
|
||||
}
|
||||
|
||||
public int getParagraphDirection(int line) {
|
||||
|
@ -251,4 +250,5 @@ public class Layout {
|
|||
protected native void native_set_ellipsize(long layout, int ellipsize_mode, float ellipsize_width);
|
||||
protected native int native_get_ellipsis_count(long layout, int line);
|
||||
protected native void native_draw(long layout, long snapshot, long paint);
|
||||
protected native void native_draw_custom_canvas(long layout, Canvas canvas, Paint paint);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue