优化自定义绘图
我在文本视图后面绘制一些自定义形状,使其看起来像一个记事本。它在顶部绘制一个重复的位图,在文本下方绘制一个白色背景,并在其余部分下方绘制一个辅助“注释”页面,以添加一些尺寸和层次感。请参阅屏幕截图:
现在,这是可绘制的 TextView 的 setDrawingCacheEnabled(true)
被应用于.应用此方法调用后,滚动非常平滑,正是我想要的。如果没有它,黑色背景就会消失,但滚动会非常不稳定。关于如何缓存此视图以便滚动平滑而不破坏我的 UI 有什么想法吗?
I'm drawing some custom shapes behind a textview to make it appear it's a notepad. It draws a repeating bitmap across the top, as well as a white background under the text, and a secondary "note" page under the rest to add a little dimension and layering. See the screenshot:
Now, this is with setDrawingCacheEnabled(true)
for the TextView this drawable is applied to. With this method call applied, the scrolling is VERY smooth, exactly what I want. Without it, the black background disappears, but the scrolling is very choppy. Any idea on how to cache this view so that scrolling is smooth without destroying my UI?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎这个函数只适用于纯色,正如我在发布之前应该阅读的文档中所定义的那样。我发现很难相信没有任何东西可以像该函数那样缓存复杂的视图和可绘制对象,但是,无论如何。活到老,学到老。
Seems this function only works with solid colors, as defined in the documentation which I should have read before posting. I find it hard to believe there's nothing that caches complex views and drawables to work as well as that function does, but, whatevs. Live 'n learn.