如何在android中单独滚动文本? [英] How to make text alone scrollable in android?

查看:69
本文介绍了如何在android中单独滚动文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Xml编码如下



< relativelayout xmlns:android =http://schemas.android.com/apk/res/android> ;

android:layout_width =fill_parent

android:layout_height =fill_parent>



< ; ImageButton

android:id =@ + id / close

android:layout_width =wrap_content

android:layout_height =wrap_content

android:layout_alignParentRight =true

android:layout_alignParentTop =true

android:src =@ drawable / close/ >



< textview>

android:id =@ + id / textView1

android :layout_width =298dp

android:layout_height =269dp

android:layout_alignParentLeft =true

android:layout_alignParentRight =true

android:layout_below =@ + id / close

android:layout_marginTop =31dp

android:text =William Shakespeare(1564年4月26日(受洗) - 1616年4月23日)[nb 1]是一位英国诗人和剧作家,被广泛认为是英国最伟大的作家和世界上杰出的剧作家。[ 1]他经常被称为英国的国家诗人,莎士比亚出生并在埃文河畔斯特拉特福(Stratford-upon-Avon)长大。在18岁时,他与安妮·海瑟薇结婚,他有三个孩子:苏珊娜,双胞胎哈姆奈特和朱迪思。 1585年至1592年间,他在伦敦开始了一个成功的职业生涯,作为一个演员,作家和一个名为Lord Chamberlain's Men的演奏公司的部分所有者,后来被称为国王的男人。他似乎已于1913年左右在49岁时退休到斯特拉特福德,三年后他去世了。很少有莎士比亚私人生活的记录存活下来,并且有很多关于他的外表等问题的猜测,[4]/>



/>





单独的文本部分我想滚动。我的图像按钮不应该被这个滚动打扰。

My Xml coding is as follows

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android">
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<ImageButton
android:id="@+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/close" />

<textview>
android:id="@+id/textView1"
android:layout_width="298dp"
android:layout_height="269dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/close"
android:layout_marginTop="31dp"
android:text="William Shakespeare (26 April 1564 (baptised) – 23 April 1616)[nb 1] was an English poet and playwright, widely regarded as the greatest writer in the English language and the world's pre-eminent dramatist.[1] He is often called England's national poet and the Shakespeare was born and brought up in Stratford-upon-Avon. At the age of 18, he married Anne Hathaway, with whom he had three children: Susanna, and twins Hamnet and Judith. Between 1585 and 1592, he began a successful career in London as an actor, writer, and part owner of a playing company called the Lord Chamberlain's Men, later known as the King's Men. He appears to have retired to Stratford around 1613 at age 49, where he died three years later. Few records of Shakespeare's private life survive, and there has been considerable speculation about such matters as his physical appearance, [4] " />

/>


The text portion alone i want to scroll.My image button should not be disturbed by this scrolling.

推荐答案

只需设置



Just set the

android:maxLines = "AN_INTEGER"

android:scrollbars = "vertical"





布局的xml文件中TextView的属性。



然后使用:





properties of your TextView in your layout's xml file.

Then use:

TextView.setMovementMethod(new ScrollingMovementMethod())




代码中的



in your code.


这篇关于如何在android中单独滚动文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆