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
时,我得到的是空值.
I'm trying to use GridLayout in json like this
{
"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"
}
]
}
I'm getting null when I am preparing a ProteusView
.
如果proteus不支持GridLayout,是否可以使用LinearLayout
或RelativeLayout
获得相同的结果
If proteus does not support GridLayout, is there a way to use LinearLayout
or RelativeLayout
to get the same result
推荐答案
Proteus当前没有GridLayout
的实现;但是您可以自己实现GridLayout
的解析器并使用它.检出名为如何注册.
Proteus currently does NOT have an implementation for GridLayout
; but you can implement the parser for GridLayout
yourself and use it. Checkout an example of a custom parser called CircleViewParser
and how to register it.
或者,您可以将LinearLayout
与layout_weight
一起使用.
Alternatively, you can use LinearLayout
with 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>
这篇关于proteus支持GridLayout吗?如果没有,那有什么替代方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!