Two TextViews side by side, only one to ellipsize?

后端 未结 6 669
我在风中等你
我在风中等你 2020-11-29 02:02

I want to have two TextView elements appear side by side (in a list item), one aligned to the left, one to the right. Something like:

|

        
6条回答
  •  失恋的感觉
    2020-11-29 02:29

    Just an idea, why don't you declare first in the xml layout the textview on the right and set its width as wrap content, android:layout_alignParentRight="true" and android:gravity="right". Then declare the textview on the left, set its width as fill parent, android:layout__toLeftOf={the id of the textview on the right} having RelativeView as the root view.

    By declaring first the right textview, its required width will be computed first and occupy the view while the textview on the left will occupy the remaining space of the view.

    I still have not tried this though it might give you some idea.

    [Update]

    I tried creating an xml resource layout... and it somehow works...

    
      
      
      
      
    
    

提交回复
热议问题