[英]how to make scrollable horizontally and vertically the contents of a TextView
I want to scroll the results that view in a TextView, this my xml: 我想滚动在TextView中查看的结果,这是我的xml:
<scroll>
<TextView
android:id="@+id/ris"
android:layout_width="wrap_content"
android:layout_height="229dp"
android:layout_weight="0.96"
android:textAppearance="?android:attr/textAppearanceMedium" />
</scroll>
but the app crashes. 但该应用程序崩溃了。
Use 采用
<ScrollView> your View "</ScrollView">
And there must be only one child ScrollView. 并且必须只有一个子ScrollView。
add this in XML file for TextView 在TextView的XML文件中添加
android:scrollHorizontally="true"
android:scrollVertically="true"
Add the following as attributes in your TextView
: 将以下内容添加为
TextView
属性:
android:maxLines = "1"
android:scrollbars = "vertical"
Then once you have instantiated your TextView
, add the line: 然后,实例化
TextView
,添加以下行:
mTextView.setMovementMethod(new ScrollingMovementMethod());
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="19dp"
android:layout_marginTop="24dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
tools:context=".Tester" />
</LinearLayout>
</ScrollView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.