我在XML定义了如下布局:如何动态膨胀布局?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/streamRelativeLayout">
<ListView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/streamListView"></ListView>
<ProgressBar android:layout_centerInParent="true" android:layout_height="wrap_content" android:id="@+id/streamProgressBar" android:layout_width="wrap_content"></ProgressBar>
</RelativeLayout>
我如何使用LayoutInflater抢ListView控件和进度,并在代码分配呢?
我有动态创建的linaerlayout是的LinearLayout ll =新的LinearLayout(上下文);这个布局有一些子视图,比如framelayout,webview。现在,我怎样才能使这个线性布局膨胀? – Karthick 2013-04-18 05:54:30
由于 避免传递null作为视图根(需要解析膨胀布局的根元素上的布局参数),因此在膨胀布局时,请避免在父视图中传入null,因为否则在膨胀布局的根上的任何布局参数都会被忽略。 – 2017-04-04 10:42:00