how to set width which is equal to another widget on android

前端 未结 7 423
走了就别回头了
走了就别回头了 2021-02-03 19:27

I need to draw a horizontal line below a text field such that the width of the line equals the text width (not the width of the full screen).

In my app I have a textview

7条回答
  •  闹比i
    闹比i (楼主)
    2021-02-03 19:47

    It depends on your use case. If you plan to modify things in the layout dynamically and have them also sized the same as the TextView, you may want to wrap them in a parent view together. If it's a one-time thing, use RelativeLayout as suggested by the other answer here.

     
    
    
    
            
    
     
    

提交回复
热议问题