GridLayout поддерживается Proteus? Если нет, то какова альтернатива? - PullRequest
0 голосов
/ 11 июля 2019

Я пытаюсь использовать GridLayout в json, как это
{ "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.

Если протеус не поддерживает GridLayout, есть ли способ использовать LinearLayout или RelativeLayout для получения того же результата

1 Ответ

1 голос
/ 12 июля 2019

Proteus в настоящее время НЕ имеет реализации для GridLayout;но вы можете самостоятельно реализовать парсер для GridLayout и использовать его.Изучите пример пользовательского парсера с именами CircleViewParser и , как его зарегистрировать .

В качестве альтернативы, вы можете использовать LinearLayout с layout_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>
...