简体   繁体   中英

Android scrollable textview on canvas

I would like to have a scrollable textview on a canvas. This post describes how to draw a textview onto a canvas and this post describes how to make a textview scrollable. If I combine them in the most straightforward way (ie just add function calls setMaxLines and setMovementMethod ) it does not work.

What are you trying to accomplish exactly? The post about using a layout to draw into a Canvas seems unnecessary in most circumstances. I have a different suggestion...

Extend TextView and provide the Canvas to it as a member (pass it in a constructor or set method). Then override the draw method and use the member Canvas to pass to super.draw. Then do whatever else you want with the Canvas.

Or, if you aren't doing anything too crazy, simply extend TextView, override onDraw, and use the Canvas passed there to do your drawing. Only in very unusual circumstances should you really need to draw the View into a separate Canvas.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM