2013-02-20 42 views
1

我在页脚中有文本视图,我想在页脚中滚动该文本。这是我的代码片段,但文本不会滚动。任何机构可以帮助我 由于提前 我的代码如何在android中获取自动滚动文本视图

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> 
+0

可能重复:http://stackoverflow.com/questions/11184054/android-auto-scrolling-text-in-textview – EvZ 2013-02-20 09:31:35

回答

1

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

+0

嗨,我试图用这个,但我不能得到..简单的文本OLY获取作为一个视图不滚动 – 2013-02-20 09:39:23

+1

当文本溢出只有textView来滚动条...尝试为TextView提供固定宽度 – Pragnani 2013-02-20 09:54:04

+0

感谢Pragnani其完美的作品,当我们给文本视图一定的宽度 – 2013-02-20 12:47:15

1

设置

android:maxLines = "AN_INTEGER" 

android:scrollbars = "vertical" 

在XML文件中的TextView中。并使用

textView.setMovementMethod(new ScrollingMovementMethod()) 
相关问题