Dyanmicaly setting the height of a scroll view

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Dyanmicaly setting the height of a scroll view

Postby joby.nk » Tue Feb 02, 2010 11:33 am

Hi all,
I am trying to set the layout params programmatically for a ScrollView but it throws exeption .

I am created a ScrollView from XMl.

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.             <ScrollView android:layout_width="fill_parent" android:id="@+id/scrlcntainer"
  2.                 android:layout_height="350dip" />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4



then change the height from the corresponding java file.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         ScrollView scrlCntainer =(ScrollView)findViewById(R.id.scrlcntainer);
  2.  
  3.         scrlCntainer.setLayoutParams(new  LayoutParams(LayoutParams.WRAP_CONTENT,   100));
Parsed in 0.065 seconds, using GeSHi 1.0.8.4



but its crashes, anybody can give me asolution
joby.nk
Junior Developer
Junior Developer
 
Posts: 13
Joined: Thu Jan 29, 2009 1:22 pm
Location: INDIA

Top

Postby icobasco » Sat Feb 06, 2010 3:19 pm

Please, give us your layout and java file. It's really hard to understand from just 3 lines :)
User avatar
icobasco
Senior Developer
Senior Developer
 
Posts: 108
Joined: Thu Jun 04, 2009 11:12 am
Location: Italy

Re: Dyanmicaly setting the height of a scroll view

Postby Rahul » Mon Feb 08, 2010 7:10 am

You must also specify the name of the parent layout within which you have placed the scroll view

Something like
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  ScrollView sc=(ScrollView)findViewById(R.id.scrlcntainer);
  2.  sc.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,100));
  3.    
Parsed in 0.057 seconds, using GeSHi 1.0.8.4


joby.nk wrote:Hi all,
I am trying to set the layout params programmatically for a ScrollView but it throws exeption .

I am created a ScrollView from XMl.

<ScrollView android:layout_width="fill_parent" android:id="@+id/scrlcntainer"
android:layout_height="350dip" />


then change the height from the corresponding java file.

ScrollView scrlCntainer =(ScrollView)findViewById(R.id.scrlcntainer);

scrlCntainer.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 100));


but its crashes, anybody can give me asolution
Rahul
Experienced Developer
Experienced Developer
 
Posts: 89
Joined: Wed Oct 01, 2008 11:16 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 7 guests