proteus 支持 GridLayout 吗?如果不是那么有什么选择?

Is GridLayout supported by proteus? If not then what is an alternative?

我正在尝试像这样在 json 中使用 GridLayout
{ "type": "GridLayout", "android": "http://schemas.android.com/apk/res/android", "orientation": "horizontal", "layout_width": "match_parent", "layout_height": "match_parent", "columnCount": "2", "rowCount": "2", "children": [ { "type": "TextView", "layout_width": "wrap_content", "layout_height": "wrap_content", "layout_columnWeight": "1", "layout_marginTop": "8dp", "layout_marginLeft": "16dp", "textSize": "20dp", "textColor": "@android:color/background_dark", "text": "244536" }, { "type": "TextView", "layout_width": "wrap_content", "layout_height": "wrap_content", "layout_columnWeight": "1", "layout_marginTop": "8dp", "layout_marginLeft": "16dp", "textSize": "20dp", "textColor": "@android:color/background_dark", "text": "244536" } ] } 我在准备 ProteusView 时得到空值。

如果proteus不支持GridLayout,有没有办法使用LinearLayoutRelativeLayout得到相同的结果

Proteus 目前没有 GridLayout 的实现;但是您可以自己为 GridLayout 实现解析器并使用它。查看名为 CircleViewParser and how to register it.

的自定义解析器示例

或者,您可以将 LinearLayoutlayout_weight 结合使用。

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal">

        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="One" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="Two" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="Three" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="Four" />

    </LinearLayout>

</LinearLayout>