TextView android:ellipsize="marquee" not working as expected

I had the same problem today and was able to figure it out. None of the listed solutions here worked so I thought I'd share what fixed it for me.

TL;DR: If you are dynamically setting the text of the TextView, try setting the required "marquee" properties in code instead of in the layout xml file.

Longer version: In my case, I had a GridView with an adapter and a TextView in each item. Some of the item's had text that was too long to fit in its "cell" of the grid, and thus I wanted all items that were too long to scroll a few times. Being that the TextView is in a GridView with an adapter, the text was obviously being set in code, from the current item of the adapter.

Through much painful debugging, I finally had the idea to set all of the marquee settings in code instead of in the layout xml file. This caused the 3 dots (...) to finally go away from the TextView and begin scrolling instead.

Here's what my layout file looks like now: (note that none of the properties listed above are set here)

<TextView
android:text="Placeholder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:id="@+id/name"
/>

And here's what my adapter code looks like:

nameView.setText(name);
nameView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
nameView.setSingleLine(true);
nameView.setMarqueeRepeatLimit(5);
nameView.setSelected(true);

Key is here to do setSelected(true); on text view.. Of course

android:ellipsize="marquee"
android:scrollHorizontally="true"

need to be set in xml as well. Without all of this marquee will not happen. Ever.