如何在android中获取Auto Scrolling文本视图

时间:2013-02-20 09:29:32

标签: android android-layout textview

我在页脚中有文本视图,我想在页脚中滚动该文本。这是我的代码片段,但该文本不可滚动。任何身体都可以帮助我 提前致谢  我的代码

public class Footer extends RelativeLayout{
    private TextView footer_TextVeiw;
    ImageView logout;
    public Footer(Context context, AttributeSet attrs) {
        super(context, attrs);
        String infService = Context.LAYOUT_INFLATER_SERVICE;
        LayoutInflater li = (LayoutInflater) getContext().getSystemService(infService);
        li.inflate(R.layout.footer_layout, this, true);
        footer_TextVeiw= (TextView) this.findViewById(R.id.text_Footer);  
        footer_TextVeiw.setSelected(true);    } }

我的XML布局

<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Footer" >


    <TextView
        android:id="@+id/text_Footer"
        android:layout_width="fill_parent"
        android:layout_height="25dp"
        android:layout_alignParentBottom="true"
        android:background="#ECEFF5"
        android:layout_centerHorizontal="true"
        android:marqueeRepeatLimit="marquee_forever"
        android:singleLine="true"
         android:scrollHorizontally="true" 
        android:ellipsize="marquee"
        android:text="@string/Footer"
         />


</RelativeLayout>

2 个答案:

答案 0 :(得分:1)

您可以尝试属性android:scrollbars="vertical" or Horizontal

答案 1 :(得分:1)

设置

android:maxLines = "AN_INTEGER"

android:scrollbars = "vertical" 

在xml文件的TextView中。并使用

textView.setMovementMethod(new ScrollingMovementMethod())