Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8569881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:26:14+00:00 2026-06-11T18:26:14+00:00

I am getting exception while setting the layoutparams of scroolview programmatically.I have tried but

  • 0

I am getting exception while setting the layoutparams of scroolview programmatically.I have tried but getting exception while doing that.This is the code:

sv = (ScrollView)findViewById(R.id.scrollView);
        sv.setBackgroundColor(Color.TRANSPARENT);

            ScrollView.LayoutParams layoutParams = new ScrollView.LayoutParams(
                    ScrollView.LayoutParams.MATCH_PARENT,
                    ScrollView.LayoutParams.MATCH_PARENT);
            layoutParams.bottomMargin = 100;
            layoutParams.setMargins(0, 0, 0, 100);
            sv.setLayoutParams(layoutParams);

This is the error log:

09-23 12:13:20.666: E/AndroidRuntime(3284): Uncaught handler: thread main exiting due to uncaught exception
09-23 12:13:20.696: E/AndroidRuntime(3284): java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.widget.RelativeLayout$DependencyGraph.findRoots(RelativeLayout.java:1291)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1238)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:279)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:299)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.view.View.measure(View.java:7964)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:569)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:361)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.view.View.measure(View.java:7964)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.view.View.measure(View.java:7964)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:464)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.view.View.measure(View.java:7964)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.view.View.measure(View.java:7964)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.view.View.measure(View.java:7964)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.view.ViewRoot.performTraversals(ViewRoot.java:763)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.os.Looper.loop(Looper.java:123)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at android.app.ActivityThread.main(ActivityThread.java:4363)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at java.lang.reflect.Method.invoke(Method.java:521)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
09-23 12:13:20.696: E/AndroidRuntime(3284):     at dalvik.system.NativeStart.main(Native Method)

This is the xml file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_centerHorizontal="true"
    android:orientation="vertical" >

    <RelativeLayout
        android:id="@+id/frameLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <ScrollView
            android:id="@+id/scrollView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="90.0dip"
            android:layout_marginLeft="1.0dip"
            android:layout_marginRight="1.0dip"
            android:layout_marginTop="-2.0dip"
            android:animateLayoutChanges="true"
            android:fadeScrollbars="true"
            android:fadingEdge="none" >

            <!-- android:layout_marginBottom="60.0dip" -->
            <!-- android:fillViewport="true" -->

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:visibility="visible" >

                <ImageView
                    android:id="@+id/QuestionImageView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:visibility="visible" />

                <TextView
                    android:id="@+id/tv"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/QuestionImageView"
                    android:fadingEdge="vertical"
                    android:scrollbars="vertical" />

                <TextView
                    android:id="@+id/questionnumber"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:fadingEdge="vertical"
                    android:scrollbars="vertical" />

                <TextView
                    android:id="@+id/question"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_below="@id/tv"
                    android:fadingEdge="vertical"
                    android:padding="10dp"
                    android:scrollbars="vertical"
                    android:text=""
                    android:textColor="@color/dark_green" />

                <RadioGroup
                    android:id="@+id/radioGroup1"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/question"
                    android:orientation="vertical" >

                    <RadioButton
                        android:id="@+id/option1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <ImageView
                        android:layout_width="fill_parent"
                        android:layout_height="1.0dp"
                        android:background="@drawable/thinnest_blue_gradient" />

                    <RadioButton
                        android:id="@+id/option2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <ImageView
                        android:layout_width="fill_parent"
                        android:layout_height="1.0dp"
                        android:background="@drawable/thinnest_blue_gradient" />

                    <RadioButton
                        android:id="@+id/option3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <ImageView
                        android:layout_width="fill_parent"
                        android:layout_height="1.0dp"
                        android:background="@drawable/thinnest_blue_gradient" />

                    <RadioButton
                        android:id="@+id/option4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />
                </RadioGroup>
            </RelativeLayout>
        </ScrollView>
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/relativequestion"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <com.google.ads.AdView
            android:id="@+id/ad"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            ads:adSize="SMART_BANNER"
            ads:adUnitId="a1501e5633125fb"
            ads:loadAdOnCreate="true"
            ads:testDevices="TEST_EMULATOR, 123456789ABCDEF" />

        <LinearLayout
            android:id="@+id/newquestion"
            android:layout_width="fill_parent"
            android:layout_height="40.0dip"
            android:layout_above="@id/ad"
            android:background="#ff777777"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/PrevButton"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_centerInParent="true"
                android:layout_marginLeft="5.0dip"
                android:layout_weight="1.0"
                android:background="@drawable/ibtn"
                android:onClick="onPrevButtonClick"
                android:text="Prev" />

            <Button
                android:id="@+id/NextButton"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_centerInParent="true"
                android:layout_marginLeft="5.0dip"
                android:layout_weight="1.0"
                android:background="@drawable/ibtn"
                android:onClick="onNextButtonClick"
                android:text="Next" />

            <Button
                android:id="@+id/SkipButton"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_centerInParent="true"
                android:layout_marginLeft="5.0dip"
                android:layout_weight="1.0"
                android:background="@drawable/ibtn"
                android:onClick="onSkipButtonClick"
                android:text="Skip" >
            </Button>

            <Button
                android:id="@+id/SubmitButton"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_centerInParent="true"
                android:layout_marginLeft="5.0dip"
                android:layout_marginRight="5.0dp"
                android:layout_weight="1.0"
                android:background="@drawable/ibtn"
                android:onClick="onSubmitButtonClick"
                android:text="Submit" />
        </LinearLayout>
    </RelativeLayout>

</RelativeLayout>

Please help me.Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:26:15+00:00Added an answer on June 11, 2026 at 6:26 pm

    The parent of your ScrollView is a RelativeLayout and for this you should use RelativeLayout.LayoutParams:

        RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) sv
                .getLayoutParams();
        lp.setMargins(0, 0, 0, 100);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am Getting a run time Exception while using this code Runtime rt =
I am getting this exception while running any JSP on my tomcat5.5 server.Do I
I am getting this exception while accessing the jax-ws web service from my client.
I am getting Following Exception while configuring the Connection Pool in Tomcat This is
I keep getting this error while setting up ehcache in Spring MVC. org.springframework.beans.factory.BeanCreationException: Error
m getting exception while taping on listView item.. @Override protected void onCreate(Bundle savedInstanceState) {
I am getting he following Exception while running my Quartz Schdular program. Below is
I am getting the following exception while adding data into database: org.hibernate.HibernateException: The database
hi i am getting the following exception while running my application and my applicationContext.xml
I am getting the error Format Exception was unhandled at Do While objectReader.Peek <>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.