Expand TextView with wrap_content until the neighbor view reaches the end of the parent

后端 未结 7 683
遇见更好的自我
遇见更好的自我 2020-12-13 14:26

I need to achieve the following layout:

\"enter

I have two TextViews in a rela

7条回答
  •  悲哀的现实
    2020-12-13 14:38

    I suggest wrapping two TextView's into LinearLayout. Then apply android:weightSum="1" to this LinearLayout and apply android:layout_weight="1" to the child TextView that must extend.

    
    
    
        
    
        
    
    
    

    Remember to set the two atributes this it to work perfectly:

    android:ellipsize="end"
    android:maxLines="1"
    

    and LinearLayout must have android:layout_width="wrap_content"

    If you would like this ViewGroup to take whole space, wrap it with another ViewGroup:

    
    
       
    
    
    

提交回复
热议问题