Я хочу отобразить один из макетов во время выполнения на основе некоторого состояния и названный макет принять площадь зала родительского макета.Xml Layout in android
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="348dp"
android:text=" "
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:id="@+id/linearlayoutdesign1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/imageView1"
android:layout_alignLeft="@+id/textView1"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/linearlayoutdesign"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</LinearLayout>
<FrameLayout
android:id="@+id/textaddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/linearlayoutdesign1"
android:background="#000000">
<TextView
android:id="@+id/txtadd"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="12sp"
android:textColor="#FFFFFF"
android:hint=" Please wait for Location Trace..."/>
</FrameLayout>
<FrameLayout
android:id="@+id/videoview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/textaddress"
android:layout_toLeftOf="@+id/textView1" >
</FrameLayout>
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="24dp"
android:src="@drawable/submitgreen" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearlayoutdesign1"
android:layout_alignParentBottom="true"
android:src="@drawable/startgreen" />
<ImageView
android:id="@+id/recordstatus_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageView2"
android:layout_marginLeft="18dp"
android:layout_toRightOf="@+id/imageView1"
android:src="@drawable/recording" />
...................
if(flag)
linearLayout.addView(tableRow, new LinearLayout.LayoutParams
(tableRow.getLayoutParams().MATCH_PARENT, tableRow.getLayoutParams().MATCH_PARENT));
else
linearLayout.addView(tableRow, new LinearLayout.LayoutParams
(tableRow.getLayoutParams().WRAP_CONTENT, tableRow.getLayoutParams().WRAP_CONTENT));
Вы можете сделать две вещи .. 1) написать макет в XML и установить видимость на основе при условии 2) Добавить макет динамически на основе условия – ashutiwari4