layout_weight 具有不同的布局类型

layout_weight with different layout types

我已成功使用 android:layout_weightLinearLayout 的相关布局参数。是否可以将该机制与其他布局类型一起使用?例如,要控制 TableLayoutGridLayout 中的列宽。 RelativeLayout怎么样?有没有其他方法可以使 TableLayout 中的列严格占据其父列的 30%?

layout_weight 目前只能在 LinearLayout 中使用。这通常不是问题,因为您几乎可以使用嵌套的 LinearLayouts 构建所有要使用权重的 UI。

For Grid Layout i found this:

"GridLayout does not provide support for the principle of weight, as defined in weight. In general, it is not therefore possible to configure a GridLayout to distribute excess space in non-trivial proportions between multiple rows or columns ... For complete control over excess space distribution in a row or column; use a LinearLayout subview to hold the components in the associated cell group."