This is XML code,
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/light_grey" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="none" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<RelativeLayout
android:id="@+id/logolayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/layout_bg" >
<ImageView
android:id="@+id/company_logo"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/iv_bg"
android:scaleType="centerInside" />
<TextView
android:id="@+id/company_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="8dp"
android:layout_toRightOf="@+id/company_logo"
android:gravity="center"
android:text="The D Corporation Inc."
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="@+id/sss_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/company_name"
android:layout_marginLeft="10dp"
android:layout_marginTop="1dp"
android:layout_toRightOf="@+id/company_logo"
android:gravity="center"
android:text="RD Sales Management"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="@+id/login_user_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/sss_name"
android:layout_marginLeft="10dp"
android:layout_marginTop="1dp"
android:layout_toRightOf="@+id/company_logo"
android:gravity="center"
android:singleLine="true"
android:textColor="#E55451"
android:textSize="15dp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/workorderlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/logolayout"
android:layout_marginTop="8dp"
android:background="@drawable/layout_bg" >
<TextView
android:id="@+id/header_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="12dp"
android:gravity="left"
android:text="Today’s Activity"
android:textSize="17dp"
android:textStyle="bold" />
<Button
android:id="@+id/id_linesp"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/header_text"
android:layout_marginTop="8dp"
android:background="@color/light_grey" />
<HorizontalScrollView
android:layout_below="@+id/id_linesp"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/lylat"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:weightSum="3" >
<TableLayout
android:id="@+id/invoice_st"
android:layout_width="0dp"
android:layout_height="88dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:background="@drawable/btn_bg"
android:paddingBottom="6dip" >
<TableRow>
....... still code flows
I have used following piece of code in class to set the width of Linear layout present inside Horizontall scrollview ,
mLinearLayout = (LinearLayout) findViewById(R.id.lylat);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(metrics.widthPixels/4, HorizontalScrollView.LayoutParams.MATCH_PARENT);
mLinearLayout.setLayoutParams(params);
app crashes while setting the width here HorizontalScrollView.LayoutParams.MATCH_PARENT
and it says java.lang.classcastexception linearLayout.layoutparams cannot be cast to framelayout.layoutparams ,, your help will be very much thankful