2012-03-06 7 views
4

ここに状況があります.2つのテキストビューを含むウィジェットがあり、その幅がレイアウトの幅を超えると、テキストをスクロールします。問題は、マーキーがボトムテキストビューで動作していますが、マーキーは上部のテキストビューでは機能していないことです。私はコードスニペットを添付しています。私が間違っていることを教えてくれませんか?マーキーのテキストがウィジェットで動作しない

<RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/left" 
     android:layout_width="97dip" 
     android:layout_height="fill_parent" > 

     <TextView 
      android:id="@+id/place" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="5dip" 
      android:ellipsize="marquee" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:lines="1" 
      android:marqueeRepeatLimit="marquee_forever" 
      android:scrollHorizontally="true" 
      android:textColor="@color/white" > 
     </TextView> 

     <TextView 
      android:id="@+id/weather_report" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/place" 
      android:ellipsize="marquee" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:lines="1" 
      android:marqueeRepeatLimit="marquee_forever" 
      android:scrollHorizontally="true" 
      android:textColor="@color/grey" > 
     </TextView> 
    </RelativeLayout> 
+0

あなたは以下のリンクを参照することができます。 http://stackoverflow.com/questions/9568023/marquee-not-working-while-using-in-multiple-textviews/9568638#9568638 – YshakPK

答えて

3

私の作品、これを試してみてください。

<TextView 
    android:id="@+id/fact" 
    android:layout_width="200dp" 
    android:text="Loading... More text to see if it spans or not and want more" 
    android:singleLine="true" 
    android:ellipsize="marquee" 
    android:marqueeRepeatLimit ="marquee_forever" 
    android:scrollHorizontally="true" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:duplicateParentState="true"> 
    <requestFocus 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:duplicateParentState="true" /> 
</TextView> 
+0

最初に、文字列のマーキー効果とスクロールを強制するには、文字列が定義された幅よりも広くなければならないことに気づきませんでした:) – VSB

0

xmlファイルのtextviewにandroid:scrollbars = "horizontal"を使用してください。 Javaコードの使用では:

textview.setMovementMethod(new ScrollingMovementMethod()); 
+1

こんにちは、私はアンドロイドを試しました:textviewsのスクロールバーは動作しません。下のものだけがスクロールでき、上のものは静的なままです。また、私はあなたがリモートビューのsetMovementMethod()メソッドを使用できるとは思わない。 – curiousguy

関連する問題