0

We can use Spannable to adjust text color, font and background in TextView and EditView. But now I want to use it in SurfaceView, there are some images and texts in my SurfaceView. I want to implements the following picture's function, I have finished the begin/end cursor handle and know the selected text's position(rect), but I have no ideas for how to mark it. so can I use Spannable on SurfaceView? any ideas for this?

enter image description here

jiabao
  • 105
  • 1
  • 10
  • `android.text.Layout#draw()` – pskink Feb 22 '17 at 06:39
  • what is this? can you give me some documents or examples? @pskink – jiabao Feb 22 '17 at 06:43
  • what is what? this is a method that draws a `Layout` on the `Canvas`, see `android.text.Layout` documentation – pskink Feb 22 '17 at 06:46
  • maybe it is a way to do this, but I know it needs the canvas of surfaceView, – jiabao Feb 22 '17 at 07:27
  • you want to draw it on this surfaceview, right? so you need its canvas – pskink Feb 22 '17 at 07:29
  • Actually I have tried to use PopupWindow, but PopupWindow is expensive, so I want to find some ideas to do this. I used follow code to get Canvas, But after this, I find PdfSurfaceView become a black View. I can't see everything except for this rect. SurfaceHolder surfaceHolder = surfaceView. getHolder() ; Canvas canvas = surfaceHolder.lockCanvas() ; // draw surfaceHolder.unlockCanvasAndPost(canvas) ; – jiabao Feb 22 '17 at 09:39
  • so did you try Layout#draw()? – pskink Feb 22 '17 at 10:14
  • I have tried it, but when I get the canvas SurfaceView will be black – jiabao Feb 23 '17 at 02:48
  • post your code then (using `Layout#draw`) – pskink Feb 23 '17 at 08:26

0 Answers0