What are the default values when you don't spe

2019-09-14 16:16发布

问题:

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