开发者

TextView without partially drawn lines

开发者 https://www.devze.com 2023-02-07 21:00 出处:网络
Would it be possible to create a TextView in Android that can scroll many lines of text, but will not draw the first or last line of text unless it can be drawn in it\'s height completely? I realize t

Would it be possible to create a TextView in Android that can scroll many lines of text, but will not draw the first or last line of text unless it can be drawn in it's height completely? I realize that it might look strange when scrolling, but I don't want to see the cut-off tops or bottoms of characters.

T开发者_如何学Che suggested solution may involve modifying the android platform.


I don't know what you mean by modifying the android platform, but there is no restriction in coding your own TextView (or extending android TextView to change the scrolling) if you want a completely new behavior.

If you really want to do this, you could change the Touch/Scrolll behavior to directly scroll to the next/previous visible line try changing the TextView Scoller (setScoller( ) method). If that doesn't work, you will have to code your own (basically getting the line position by textview.getLayout().getLineTop(line number) and positioning the screen top to that point).

The only restriction you have is when you need to change something that is embedded within the “kernel” (like, for example, a media protocol from MediaPlayer).

Check this marquee example


See if you can use this class http://developer.android.com/reference/android/text/method/ScrollingMovementMethod.html along with the scroller. Your textView height needs to be a multiple of your text line height.


Amazingly, I would advise you to use the WheelView by Yuri

If you choose your a good combination of background, height, and width; you will get the effect that you want exactly.


The Android Terminal Emulator project includes a library with an EmulatorView class that behaves pretty much the way I want and is open source: https://github.com/jackpal/Android-Terminal-Emulator

It contains a fair amount of extra code for terminal stuff though but that could be stripped out probably if necessary. However I must assume that it supports only monospace fonts which makes it less useful.

0

精彩评论

暂无评论...
验证码 换一张
取 消