I am using ListView to implement a timeline. I enabled FastScroll and used SectionIndexer so that user could drag the scrollbar and see the section text displayed.

我正在使用ListView来实现时间线。我启用了FastScroll并使用了SectionIndexer,这样用户就可以拖动滚动条并查看显示的节文本。

The problem is all these are built-in UI. The textview that displays the section text is too small for me, I am trying to display 05pm and it's too long for the textview(or other UI?).

问题是这些都是内置的UI。显示section文本的textview对我来说太小了,我试图显示05pm,而对于textview(或其他UI?)来说太长了。

Any easier way to resolve this? For instance, a method I can set the font size of the section text or the textview layout?

有更简单的方法来解决这个问题吗?例如,我可以设置section文本的字体大小或textview布局的方法?

Thanks!

谢谢!

1 个解决方案

#1


1

Looking through the source code for AbsListView, you can find the class that handles the fast scrolling mechanism which ends up being FastScroller. FastScroller actually draws the image drawable and text on the canvas that was provided to the AbsListView like so...

查看AbsListView的源代码,您可以找到处理快速滚动机制的类,它最终是FastScroller。FastScroller实际地在画布上绘制出可以绘制的图像和文本,并把它们提供给AbsListView,就像这样……

canvas.drawText(mSectionText, (int) (rectF.left + rectF.right) / 2 - hOff, (int) (rectF.bottom + rectF.top) / 2 + mOverlaySize / 4 - descent - vOff, paint);

The code above actually draws the text on top of the bottom image drawable so it does not respect the bounds of the bottom drawable, which is why the text is actually overflowing and not being cut off. As to why this is designed this way? My guess is that the intention of the index feature was to be mainly used for single characters such as A, B, C, etc... and therefore the fast scroll index feature was designed to fit that.

上面的代码实际上是在底部图像drawable之上绘制文本,这样它就不会遵守底部drawable的边界,这就是为什么文本实际上是溢出而不是被截断的原因。我的猜测是,索引功能的意图主要用于单个字符,如A、B、C等。因此,快速滚动索引特性是设计来适应的。

So, to give a definite answer to your question, there's really no way to change the text size or change how the text is being drawn unless you modify AbsListView and FastScroller to suit your need.

所以,要给你的问题一个明确的答案,除非你修改AbsListView和FastScroller以适应你的需要,否则真的没有办法改变文本大小或者改变文本的绘制方式。

更多相关文章

  1. Alibaba Java开发手册索引规约学习笔记
  2. 为什么我们应该将XMPP而不是JSON用于简单(仅文本)消息传递应用程序
  3. 将常量文本放在EditText中,这应该是不可编辑的——Android
  4. Java - 检查所有行中现有文本的.txt
  5. 关于LSA的相关学习---短文本聚类涉及到的知识,一种主题模型(原载于
  6. 请问用Java如何逐行的读取一个文本文件呀?我现在只能完整读取.
  7. 怎么在html,Javascript,vBscript中实现从网页上接收数据存入文本
  8. 帮忙解析一下 java解析普通的文本文件,提取信息到execl文件中
  9. 基于内容估计文本宽度的算法

随机推荐

  1. Android 动画(anim)详解
  2. Android ListView控件基本用法
  3. android 布局详解
  4. android开发系列文章集合
  5. 短视频源码,实现文字横向移动效果(跑马灯
  6. Android(安卓)打包成APK
  7. Android文字的阴影效果
  8. android 动态菜单组件
  9. Android软键盘回车键修改为搜索按键
  10. android – 页面初始化时让组件得不到焦