运行TextView失败/错误(单行选框)

问题描述 投票:1回答:1

我试图让我的textview以无限的方式从左到右运行。但不知怎的,它看起来很奇怪我甚至无法用文字解释它所以我决定录制并上传它。

这是视频:https://www.youtube.com/watch?v=gj3FF7fEutk&feature=youtu.be

这就是我写Textview的方式:

<TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            android:singleLine="true"
            android:ellipsize="marquee"
            android:marqueeRepeatLimit ="marquee_forever"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:scrollHorizontally="true"

            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="Title"
            android:layout_marginTop="20dp"
            android:textColor="@color/white"
            android:id="@+id/textView_title_full"
            android:layout_centerHorizontal="true" />

这个TextView在RelativeLayout中声明如下:

<RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="170dp"
            android:id="@+id/BELOW_FULL"
            android:layout_gravity="bottom"
            android:background="@drawable/color_below_player_full"
            android:layout_below="@+id/viewpager_albumart_full"
            android:layout_alignParentBottom="true">

RelativeLayout也在Relativelayout中,如下所示:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1"
android:background="#0E0E0E">

我当然使用了txt_song_title.setSelected(true);方法。

它看起来像我想要实现的目标:https://www.youtube.com/watch?v=o4uAA4pik68

非常感谢你们!

编辑:

我用TextView做的所有部分:

public void init_textviews()
{
        ...
        txt_song_title = (TextView)findViewById(R.id.textView_title_full);
        txt_song_title.setSelected(true);
} 

//在我的onCreate方法中调用init_textviews()

txt_song_title.setText("Some Long text"); // called in onCreate after init_textviews()

最后:

public static void update_GUI_full (Context context) //Called when it is a button is clicked
{
    ...
    txt_song_title.setText("longTexthere");
    ...
}
java android android-layout textview marquee
1个回答
1
投票

与@Ahmet Kazaman并肩工作,我们发现,当使用TextView定期更新选框TextView和另一个Handler时似乎存在问题。

经过一些测试,我们发现这种奇怪的行为只发生在TextViews是一个RelativeLayout并且当封闭布局是LinearLayout时所有东西都如预期的那样。因此,解决方案(更多的解决方法)是将封闭布局更改为Linearlayout

© www.soinside.com 2019 - 2024. All rights reserved.