我有一个从 Android TextView 派生的类来自定义一个基于此示例滚动文本的 TextView:原始示例代码
我的问题是,根据滚动期间文本的大小,文本在不同的位置被截断。例如,当文本大小小于 100 时,某些 90 个字符长的文本可以正常滚动,但如果文本大小设置为 240(因此它在横向模式下填充了我的手机高度),则文本在字符位置 83 处被截断。较大的文本大小越被截断。
好像有某种内存限制?
ScrollTextView scrolltext;
scrolltext.setTextSize(TypedValue.COMPLEX_UNIT_PX, xtextsize);
scrolltext.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
scrolltext.setSingleLine(true);
scrolltext.setEllipsize(null);
scrolltext.setMaxLines(1);
scrolltext.startScroll();
并在课堂上
setHorizontallyScrolling(true);
mSlr = new Scroller(this.getContext(), new LinearInterpolator());
setScroller(mSlr);
int scrollingLen = calculateScrollingLen()
int duration = (new Double(((scrollstart.mRndDuration*10)/getWidth())*getText().length())).intValue();
setVisibility(VISIBLE);
mSlr.startScroll(mXPaused, 0, scrollingLen, 0, duration);
如果有人想尝试重新创建问题,可以使用原始示例代码重新创建问题。
那么有没有人知道为什么文本会根据文本大小在不同的位置被截断?
我的布局
<LinearLayout
android:id="@+id/ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.test.testing.ScrollTextView
android:id="@+id/scrolltext"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:textSize="20sp"/>
</LinearLayout>
提前致谢
进一步:当使用不同的字体时,当使用相同的文本大小时,截断开始的位置会改变。看起来仍然像资源问题,但在哪里增加缓冲区?