Why would layout_width=“wrap_content” take up the entire width of the screen?

前端 未结 3 1746
梦如初夏
梦如初夏 2021-01-29 02:46

With this xml:


    
3条回答
  •  暖寄归人
    2021-01-29 03:19

    Your problem is that the width specification in your xml is ignored. From the docs for TableRow:

    The children of a TableRow do not need to specify the layout_width and layout_height attributes in the XML file. TableRow always enforces those values to be respectively MATCH_PARENT and WRAP_CONTENT.

    P.S. Did you have a compelling reason to use absolute pixels? That's generally considered bad practice.

    P.P.S. Double-posting my answer to go with the double-posting of your question. :)

提交回复
热议问题