/ /スクロールしているテキストビューがAndroidではスクロールしていません。 - アンドロイド、テキストビュー

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>

回答:

回答№1は1

ちょうどこれらの行をあなたのxmlに入れてください:

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);

回答№2の場合は1

今はスクロールしています。 maxLines="1"singleLine="true" 、あなたはそれがちょっと変わっていることを知っています。 singleLinemaxLines IDEが私に maxLines の代わりに singleLine すでに廃止されているためです。


回答№3の場合は0

このコードをアクティビティに追加する

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