2013-02-20 66 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()) 
相關問題