I’m using the following XML file for creating a layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget28"
android:layout_width="fill_parent"
android:layout_height="80px">
<LinearLayout
android:id="@+id/linearText"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_marginLeft="10px"
android:layout_marginTop="10px">
<TextView
android:id="@+id/txtAirLineCodeLv"
android:text="TextView" />
<ImageView
android:id="@+id/StopDetailBtnLv"/>
<TextView
android:id="@+id/txtPriceLv"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imgFlightLogoLv" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/txtTotalDurationLv"
android:text="TextView" />
<TextView
android:id="@+id/txtStopCountLv"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/txtOrgLv"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
But when I load this file by using a following code:
view = context.LayoutInflater.Inflate(Resource.Layout.CustomizeSearchResult, parent, false) as LinearLayout;
a RuntimeException is thrown. I think I have problem in the layout but I’m not able to find that. Because when I load another XML file in place of that, then no error is showed and it run successfully.
Here you did not set the
heightandweightto theImageViewandTextView.Graphic layout will be visible to you if you give proper
height and weightto the UI Elements.If you want to set the height and weight to the UI elements programmatically, you can set the height and weight using java. You need not worry about the sizes given in the
XMLlayout.I am sure these height and weight will be changed at runtime.
change your xml as like this