android TextView不用ScrollViewe也可以滚动的方法

TextView textview = (TextView) findViewById(R.id.text);
            /**             *
             * 只有调用了该方法,TextView才能不依赖于ScrollView而实现滚动的效果。
             * 要在XML中设置TextView的textcolor,否则,当TextView被触摸时,会灰掉。
             */

            textview.setMovementMethod(ScrollingMovementMethod.getInstance());
<TextView
   xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:textSize="18sp"
  android:scrollbars="vertical"
   android:maxLines="12"
  android:textColor="@color/white"
  android:text="@string/str"
  android:id="@+id/text"
  ></TextView>
时间: 2024-08-24 19:09:01

android TextView不用ScrollViewe也可以滚动的方法的相关文章

TextView不用ScrollViewe也可以滚动的方法

转自:http://www.jb51.net/article/43377.htm android TextView不用ScrollViewe也可以滚动的方法. TextView textview = (TextView) findViewById(R.id.text);            /**             *              * 只有调用了该方法,TextView才能不依赖于ScrollView而实现滚动的效果.             * 要在XML中设置TextV

Android textview 同时改变字符串中部分字体的颜色与大小

Android TextView 改变字体主要有两种方法: 1.Html.fromHtml 获取一个用html格式表示的Spanned. 2.另一种方式是直接构造使用一个Spanned. 若要同时改变字符串中部分字体的颜色与大小,采用第一种方式 html.fromHtml,用font标签来实现时,不幸的是Android中对font的属性只支持color与face,但不支持size.那么完全使用font标签的html,是实现不了了. 使用html改变字体大小的,可以尝试<small>或<h

android TextView实现滚动显示效果

在android中,如果设置了TextView控件为单行显示,且显示的文本太长的话,默认情况下会造成显示不全的情况,这种情况下我们需要设置该控件属性如下: <TextView android:id="@+id/tv1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" and

Android TextView 横向滚动(跑马灯效果)

Android TextView 中当文字比较多时希望它横向滚动显示,下面是一种亲测可行的方法. 效果图: 1.自定义TextView,重写isFocused()方法返回true,让自定义TextView一直处于获取焦点状态. package com.example.shen.marqueedemo; import android.content.Context; import android.util.AttributeSet; import android.widget.TextView;

android如何写一个循环文字滚动的TextView

效果图: 在layout中这样来声明: <com.kaixin001.view.ScrollText android:id="@+id/news_statustxt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="10dp" android:paddingRight="1

[androidUI特效]android中TextView中如何设置水平滚动效果

如何让文本实现走马灯的效果,下面就一起实现下吧~~~~~~ package irdc.ScrollingText; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class ScrollingText extends Activity { public TextView t1; /** Called when the activity is first c

Android:TextView 自动滚动(跑马灯) (转)

Android:TextView 自动滚动(跑马灯) TextView实现文字滚动需要以下几个要点: 1.文字长度长于可显示范围:android:singleLine="true" 2.设置可滚到,或显示样式:android:ellipsize="marquee" 3.TextView只有在获取焦点后才会滚动显示隐藏文字,因此需要在包中新建一个类,继承TextView.重写isFocused方法,这个方法默认行为是,如果TextView获得焦点,方法返回true,失

Android TextView跑马灯效果

TextView跑马灯简单效果 <!--简单示例--> <TextView android:text="@string/longWord" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textView1" android:ellipsize="marquee&quo

android textview 实现跑马灯效果

跑马灯效果最重要的就是四个属性,分别是: android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:singleLine="true" 控件的宽度,不一定是具体的值,可以是math_parent,如果想让textview中的文字滚动的话,那里面内容的长度肯定是要大于控件的长度的,不然滚动还有啥