Android Layout Overflow Concern

2019-07-28 23:50发布

I was doing a quick mockup for a song_item.xml file that will go into a listView.

The first picture is the desired "output", however, if the song title is too long, then it will overflow into the second line; hiding the group name!

So the second picture is NOT the desired "output"

What are ways to overcome this, and then

* * MAYBE * * has Google stated why there are only 3 layout choices? Match Parent, Fill Parent, and Wrap Content? Why not some layout abilities for "stationary overflows". You see people programmatically create solutions that achieve things like scrolling textViews, etc...

enter image description here enter image description here


Based on suggestion from user1374864 (the accepted answer)

This is the output that occurs with the input from the second picture, but uses a modified versions of user1374864's answer. I might decide to go with the marquee, but for right now...this is good!

enter image description here

1条回答
We Are One
2楼-- · 2019-07-29 00:50

you can add the following lines to the Textview of the song title.

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

It forces your TextView to be only a singleline and marquee the text if it is too long.

查看更多
登录 后发表回答