TextView的滚动不工作 [英] Textview scrolling not working
问题描述
我要滚动文本向下和向上垂直,柜面出现在文本中的TextView比空间更长时间。
但是,下面的方法我测试,不工作。
1 - tv1.setMovementMethod(新ScrollingMovementMethod());
此外,在使用这种方法,调用 onFling()
方法停止工作。
2 - 使用<&滚动型GT;
布局XML。
同时,使用这种方法时,调用 onFling()
方法停止工作。
<滚动型
机器人:ID =@ + ID / SCROLLER_ID
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:滚动条=垂直
机器人:fillViewport =真正的> <的TextView
机器人:ID =@ + ID / TEXT_STATUS_ID
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:layout_weight =1.0/>< /滚动型>
我在布局XML的TextView如下。
<的TextView
机器人:ID =@ + ID / textView1
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:layout_weight =2.26
机器人:背景=@绘制/绿
机器人:比重=中心
机器人:文字=大文本
机器人:textAppearance =:/>中的Android ATTR / textAppearanceLarge?
您不能有一个滚动查看
,如的TextView
或的ListView
,在滚动型
。
因此,请使用简单的的TextView
正常布局内机器人添加:滚动条
属性,它
<的TextView
机器人:ID =@ + ID / textView1
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:行=3
机器人:滚动条=垂直
机器人:scrollbarStyle =insideOverlay
机器人:fadeScrollbars =真
机器人:fadingEdge =垂直/>
在活动
端你必须写一样的东西:
tv1.setMovementMethod(新ScrollingMovementMethod());
(基本上Ø你的第一点所描述的同样的事情)
I want to scroll text down and up vertically, incase the text to appear in the textview is longer than the space. However, the below methods I tested, do not work.
1 - tv1.setMovementMethod(new ScrollingMovementMethod());
Moreover, upon using this method, calls to onFling()
method stop to work.
2 - using <ScrollView>
in layout XML.
also, when using this method, calls to onFling()
method stop to work.
<ScrollView
android:id="@+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">
<TextView
android:id="@+id/TEXT_STATUS_ID"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0"/>
</ScrollView>
my TextView in layout XML is the following.
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2.26"
android:background="@drawable/green"
android:gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
You can't have a scrollable View
, like TextView
or ListView
, inside a ScrollView
.
So use your simple TextView
inside a normal layout and add android:scrollbars
property to it.
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:lines="3"
android:scrollbars="vertical"
android:scrollbarStyle="insideOverlay"
android:fadeScrollbars="true"
android:fadingEdge="vertical" />
In the Activity
side you must write something like:
tv1.setMovementMethod(new ScrollingMovementMethod());
(Basically the same thing o described at your first point)
这篇关于TextView的滚动不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!