什么是 java 在编程上等效于创建以下XML
文件:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout />
</LinearLayout>
我尝试这样做,但有些LinearLayout
如何MATCH_PARENT
// child is the RelativeLayout in the above example:
LinearLayout parent = new LinearLayout(getContext());
LinearLayout.LayoutParams childLayoutParams = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
parent.addView(child, -1, childLayoutParams);