What are the default values when you don't specify height and width for elements inside a table layout?

旧巷老猫 提交于 2019-12-12 04:53:31

问题


I noticed that when working with a table layout, you don't have to specify layout_width and layout_height for elements inside it.(doesn't bring up a compiler(not sure if its a compiler) or a layout error). That is, it is perfectly valid to have something like this inside a table layout

    <TableRow
    android:id="@+id/tableRow3"
    android:padding="@dimen/activity_horizontal_margin" >

I assuming that the table layout gives default values for width and height. Does anyone know what these values are? I tried looking this up on google and on other threads here but couldn't find anything.


回答1:


Your example is not just valid, it would ignore width and height.

"The children of a TableLayout cannot specify the layout_width attribute. Width is always MATCH_PARENT. However, the layout_height attribute can be defined by a child; default value is WRAP_CONTENT. If the child is a TableRow, then the height is always WRAP_CONTENT."

You really should look more often at this site http://developer.android.com/reference/android/widget/TableLayout.html



来源:https://stackoverflow.com/questions/26072522/what-are-the-default-values-when-you-dont-specify-height-and-width-for-elements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!