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

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

With this xml:


    
相关标签:
3条回答
  • 2021-01-29 02:58

    Dont understand....
    Cant see layout_width attribute,layout_height attribute for TableRow.no Elements can be without these attributes.

    0 讨论(0)
  • 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. :)

    0 讨论(0)
  • 2021-01-29 03:21

    Have you looked at this question?

    Button width in Android TableLayout

    The issue could be caused by using android:stretchColumns="*" in your TableLayout, but it is difficult to tell without the rest of your XML.

    0 讨论(0)
提交回复
热议问题