2016-12-15 16 views
0

私の文章をポストhereとしてスクロールしています。Androidでは、スクロールしているテキストビューがスクロールしていません。

Javaコードがなくても別のレイアウトで初めてスクロールしているのが分かりました。 今、それはもはやスクロールしていません。これに何が間違っているのか分かりません。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingTop="?attr/actionBarSize"> 

    <LinearLayout 
     android:id="@+id/scrollingTextLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:background="#0792B5" 
     android:gravity="center_vertical" 
     android:orientation="horizontal"> 

     <TextView 
      android:id="@+id/scrollingText" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:ellipsize="marquee" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:marqueeRepeatLimit="marquee_forever" 
      android:maxLines="1" 
      android:padding="5dp" 
      android:scrollHorizontally="true" 
      android:text="The culture of India is the way of living of people of India." 
      android:textColor="#FFFFFF" 
      android:textSize="16sp" /> 

    </LinearLayout> 

    <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/pager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/scrollingTextLayout" 
     android:background="@android:color/darker_gray" /> 

</RelativeLayout> 
+0

レイアウトの幅をandroid:layout_width = "wrap_content"に設定してから、 – Pavya

+0

を実行してください。同じ。まだスクロールしていません。 –

+0

あなたのコードで 'textView.setSelected(true)'を試してください。あなたはXMLのtextviewにアンドロイド:singleLine = "true"を追加してみてください。onCreateViewのTextViewにフォーカスを合わせてみてください。(source):[リンク](http://stackoverflow.com/a/3333855/5373110) – Meet

答えて

1

をこのコードを追加します。

android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:singleLine="true" 
android:ellipsize="marquee" 
android:marqueeRepeatLimit="marquee_forever" 
android:singleLine="true" 
android:scrollHorizontally="true" 

そして、あなたのコード内:

textView.setSelected(true); 
+1

setSelected(true)は必要ありませんが動作します。 –

+1

この情報をお寄せいただきありがとうございます。 – Bhavnik

0

ちょうどあなたのXMLでこれらの行を入れて活動して

TexView tv=findViewbyId(R.id.scrollingText); 
tv.setSelected(true); 
+0

動作しません。 maxLines = "1"にsingleLineを変更したときに動作しています –

1

それは今のスクロールです。私はちょうどmaxLines="1"singleLine="true"に変更しました。私はsingleLinemaxLinesに変更しました。これは、IDEが既にsingleLineの代わりにmaxLinesを使用するように提案したためです。

+1

ありがとうございますが、documentによると、singleLineはマーキーのために働いていますが、maxLinesはtextLinesをこれまでと同じくらい背の高いものにしています。テキストを複数の行に折り返させるのではなく、1つの水平方向にスクロールする行に制限する – Bhavnik

関連する問題