0

I am trying to create a table where the 1st column is a "subject" that doesn't scroll and the 2nd column is text that scrolls using a marquee format. In the example below, the subject: "Astrology" would not scroll but the text in column 2 should scroll. I'm using a table as I want to have the subject and scrolling text on the same line. When I run this, the text in column 2 does not scroll. However, if I remove the <"TableRow"> tags from activity_main.xml, the marquee text scrolls but it is not on the same line.

Is it possible to scroll text in 1 column of a table row and not scroll the text in another column of the same row?

Example: (The 1st column subject: "Astrology" should not scroll)

| 1st column | 2nd column |

Astrology: <-- Capricorn: This text scrolls from right to left <--

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@android:color/black"
    android:textColor="#FFFFFFFF"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:stretchColumns="1">

    <TableRow>
        <TextView
            android:layout_column="1"
            android:textColor="#FFFFFFFF"
            android:text="Astrology:"
            android:padding="3dip" />
        <TextView
            android:layout_height="wrap_content"
            android:textColor="#FFFFFFFF"
            android:text="Capricorn: This is a test of the emergency broadc ..."
            android:id="@+id/tvText1"
            android:layout_width="fill_parent"
            android:singleLine="true"
            android:ellipsize="marquee"
            android:marqueeRepeatLimit="marquee_forever"
            android:scrollHorizontally="true"
            android:paddingLeft="15dip"
            android:paddingRight="15dip"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:freezesText="true" />
    </TableRow>

MainActivity:

import android.os.Bundle;
import android.app.Activity;
import android.widget.TextView;

public class MainActivity extends Activity {
    TextView tvText1,tvText2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tvText1 = (TextView)findViewById(R.id.tvText1);
        tvText2 = (TextView)findViewById(R.id.tvText2);

        tvText1.setSelected(true);
        tvText2.setSelected(true);
    }

1 Answers1

0

I was able to get this to work using Ramakrishna's ScrollTextView solution that lets you change the scrolling speed. Here's that link: Marquee Set Speed I replaced the 2nd column TextView with the ScrollTextView as shown below.

<TableRow>
    <TextView
        android:layout_column="1"
        android:textColor="#FFFFFFFF"
        android:text="Astrology:"
        android:padding="3dip" />
    <TextView
    <com.example.jack.tablemarquee.ScrollTextView
        android:layout_height="wrap_content"
        android:textColor="#FFFFFFFF"
        android:text="Capricorn: This is a test of the emergency broadcast system. Had this been an actual emergency..."
        android:id="@+id/scrolltext"
   />
</TableRow>