在Android中,滚动文本视图不是滚动。

在Android中,滚动文本视图不是滚动。,android,textview,Android,Textview,我正在使我的文本作为帖子滚动 我想我第一次看到它在另一个布局中滚动,即使没有任何java代码。 但是现在,它不再滚动了。不知道这有什么问题 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTo

我正在使我的文本作为帖子滚动

我想我第一次看到它在另一个布局中滚动,即使没有任何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>

在活动中添加此代码

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

在活动中添加此代码

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

只需在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);

只需在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);

现在正在滚动。我刚把
maxLines=“1”
改成
singleLine=“true”
,你知道这有点奇怪。我将
singleLine
更改为
maxLines
,因为IDE建议我使用
maxLines
而不是
singleLine
,因为它已经被弃用了。

现在正在滚动。我刚把
maxLines=“1”
改成
singleLine=“true”
,你知道这有点奇怪。我将
singleLine
更改为
maxLines
,因为IDE建议我使用
maxLines
而不是
singleLine
,因为它已经被弃用了。

设置版面宽度android:layout\u width=“wrap\u content”然后设置tryDone。相同的。仍然没有滚动。请尝试在代码中使用
textView.setSelected(true)
。来源:请尝试将以下内容添加到XML中的textview:android:singleLine=“true”,并尝试在onCreateView()中的textview上设置焦点,或者在需要字幕开始滚动时设置焦点。它现在正在滚动。我刚把maxLines=“1”改为singleLine=“true”,你知道这有点奇怪。我将singleLine更改为maxLines=“1”,因为IDE建议我使用maxLines而不是singleLine,因为它已经被弃用了。设置版面宽度android:layout\u width=“wrap\u content”,然后设置tryDone。相同的。仍然没有滚动。请尝试在代码中使用
textView.setSelected(true)
。来源:请尝试将以下内容添加到XML中的textview:android:singleLine=“true”,并尝试在onCreateView()中的textview上设置焦点,或者在需要字幕开始滚动时设置焦点。它现在正在滚动。我刚把maxLines=“1”改为singleLine=“true”,你知道这有点奇怪。我将singleLine更改为maxLines=“1”,因为IDE建议我使用maxLines而不是singleLine,因为它已经被弃用了。它不起作用。当我将singleLine更改为maxLines=“1”时,它现在可以工作了。它不工作。当我将singleLine更改为maxLines=“1”是的,singleLine适用于marquee,尽管它已被弃用,但根据文档,maxLines使文本行与我们给出的文本行一样高,而singleLine意味着将文本限制为单个水平滚动行,而不是将其包装到多个行上,singleLine适用于marquee,尽管它已被弃用,根据文档,maxLines使文本行与我们给出的文本行一样高,而singleLine的意思是将文本限制为单个水平滚动行,而不是将其包装到多行