我想创建一个函数,它返回在View
中设置的属性或属性的JsonObject假设我有LinearLayout,其中包含一个TextView和一个Button
LinearLayout
width = (match_parent)
height = (match_parent)
orientation = "vertical"
----- Button
width = (wrap_parent)
height = (wrap_parent)
text = "Button"
----- TextView
width = (wrap_parent)
height = (wrap_parent)
text = "TextView"
我想创建函数,因为我将传递LinearLayout的对象,它将返回带有所有属性的JsonObject
{
"LinearLayout": {
"android:width": "match_parent",
"android:height": "match_parent",
"android:orientation": "vertical",
"child_view": {
"Button": {
"android:width": "wrap_content",
"android:height": "wrap_content",
"android:text": "Button"
},
"TextView": {
"android:width": "wrap_content",
"android:height": "wrap_content",
"android:text": "TextView"
}
}
}
}
是否可能,因为我想存储视图,所以我认为这是唯一的方法,如果我创建它的JSON并优先存储它,之后如果我想使用我将检索JSON并创建动态视图