4

ScrollView inside my layout is not working. The question might be a silly one. I already wasted an hour with it.

Here is my XML layout:

 <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="1100dp" android:layout_height="1500dp" android:fillViewport="true" android:background="#f7f7f7" android:layout_weight="1" android:orientation="vertical" android:padding="25dp" > <LinearLayout android:id="@+id/container" android:layout_width="1100dp" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:id="@+id/account_heading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:text="ACCOUNT" android:textColor="#f44b3b" android:textSize="18dp" /> <LinearLayout android:layout_width="900dp" android:layout_height="2dp" android:layout_marginBottom="10dp" android:background="#f44b3b" > </LinearLayout> <RelativeLayout android:layout_width="1100dp" android:layout_height="wrap_content" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:text="Email" android:textColor="#333333" android:textSize="22dp" /> <EditText android:id="@+id/email" android:layout_width="500dp" android:layout_height="wrap_content" android:layout_marginLeft="300dp" android:layout_toRightOf="@+id/textView1" android:ems="10" android:inputType="textEmailAddress" > </EditText> </RelativeLayout> <LinearLayout android:layout_width="900dp" android:layout_height="1dp" android:layout_marginBottom="10dp" android:background="#c6c6c6" > </LinearLayout> <RelativeLayout android:layout_width="1100dp" android:layout_height="wrap_content" > <TextView android:id="@+id/change_password" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:text="Change Password" android:textColor="#333333" android:textSize="22dp" /> <EditText android:id="@+id/change_password_et" android:layout_width="500dp" android:layout_height="wrap_content" android:layout_marginLeft="170dp" android:layout_toRightOf="@+id/change_password" android:ems="10" android:inputType="text" > </EditText> </RelativeLayout> <LinearLayout android:layout_width="900dp" android:layout_height="1dp" android:layout_marginBottom="10dp" android:background="#c6c6c6" > </LinearLayout> <RelativeLayout android:layout_width="1100dp" android:layout_height="wrap_content" > <TextView android:id="@+id/facebook" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:text="Facebook" android:textColor="#333333" android:textSize="22dp" /> <EditText android:id="@+id/facebook_et" android:layout_width="500dp" android:layout_height="wrap_content" android:layout_marginLeft="255dp" android:layout_toRightOf="@+id/facebook" android:ems="10" android:inputType="text" > </EditText> </RelativeLayout> <LinearLayout android:layout_width="900dp" android:layout_height="1dp" android:layout_marginBottom="10dp" android:background="#c6c6c6" > </LinearLayout> <RelativeLayout android:layout_width="1100dp" android:layout_height="wrap_content" > <TextView android:id="@+id/twitter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:text="Twitter" android:textColor="#333333" android:textSize="22dp" /> <EditText android:id="@+id/twitter_et" android:layout_width="500dp" android:layout_height="wrap_content" android:layout_marginLeft="280dp" android:layout_toRightOf="@+id/twitter" android:ems="10" android:inputType="text" > </EditText> </RelativeLayout> <LinearLayout android:layout_width="900dp" android:layout_height="1dp" android:layout_marginBottom="10dp" android:background="#c6c6c6" > </LinearLayout> <TextView android:id="@+id/profile_heading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" android:text="Heading" android:textColor="#f44b3b" android:textSize="18dp" /> <LinearLayout android:layout_width="900dp" android:layout_height="2dp" android:layout_marginBottom="10dp" android:background="#f44b3b" > </LinearLayout> <RelativeLayout android:layout_width="1100dp" android:layout_height="wrap_content" android:layout_marginBottom="10dp" > <TextView android:id="@+id/Gender" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:text="Gender" android:textColor="#333333" android:textSize="22dp" /> <Spinner android:id="@+id/gender_spinner" android:layout_width="500dp" android:layout_height="wrap_content" android:layout_marginLeft="280dp" android:layout_toRightOf="@+id/Gender" /> </RelativeLayout> <LinearLayout android:layout_width="900dp" android:layout_height="1dp" android:layout_marginBottom="10dp" android:background="#c6c6c6" > </LinearLayout> <RelativeLayout android:layout_width="1100dp" android:layout_height="wrap_content" android:layout_marginBottom="10dp" > <TextView android:id="@+id/Birthday" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="170dp" android:text="Birthday" android:textColor="#333333" android:textSize="22dp" /> <Button android:id="@+id/setDate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@+id/Birthday" android:onClick="showDatePickerDialog" android:text="Pick date" /> <EditText android:id="@+id/birthdayet" android:layout_width="500dp" android:layout_height="wrap_content" android:layout_marginLeft="100dp" android:layout_toRightOf="@+id/Birthday" android:ems="10" android:inputType="text" android:text="Birthday" android:textColor="#f44b3b" android:textSize="18dp" > </EditText> </RelativeLayout> <LinearLayout android:layout_width="900dp" android:layout_height="1dp" android:layout_marginBottom="10dp" android:background="#c6c6c6" > </LinearLayout> <RelativeLayout android:layout_width="1100dp" android:layout_height="wrap_content" android:layout_marginBottom="10dp" > <TextView android:id="@+id/zipcode" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:text="Zip Code" android:textColor="#333333" android:textSize="22dp" /> <EditText android:id="@+id/zip" android:layout_width="500dp" android:layout_height="wrap_content" android:layout_marginLeft="270dp" android:layout_toRightOf="@+id/zipcode" android:ems="10" android:inputType="number" > </EditText> </RelativeLayout> <LinearLayout android:layout_width="900dp" android:layout_height="1dp" android:layout_marginBottom="10dp" android:background="#c6c6c6" > </LinearLayout> <TextView android:id="@+id/heading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" android:text="COOL" android:textColor="#f44b3b" android:textSize="18dp" /> <LinearLayout android:layout_width="900dp" android:layout_height="2dp" android:layout_marginBottom="8dp" android:background="#f44b3b" > </LinearLayout> </LinearLayout> </ScrollView> 
5
  • Not working means? What is the problem? And have you added </Scrollview> in xml? Commented Nov 14, 2012 at 13:02
  • 4
    use android:layout_width="fill_parent " android:layout_height="fill_parent" and remove layout weight Commented Nov 14, 2012 at 13:05
  • do you want horizontal scroll or vertical scroll? Commented Nov 14, 2012 at 13:06
  • @TechEnd it worked nicely. Great. Thanks! how can I accept this as answer? :) Commented Nov 14, 2012 at 13:09
  • you can't accept comment as an answer. better you post your answer and accept it.. Commented Nov 14, 2012 at 13:11

7 Answers 7

4

Remove the

android:layout_weight="1" android:orientation="vertical" 

from the scroll view. And fill_parent the layout height..

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="1100dp" android:layout_height="fill_parent" android:fillViewport="true" android:background="#f7f7f7" android:padding="25dp" > 
Sign up to request clarification or add additional context in comments.

Comments

1

Replaced this inside the ScrollView property

android:layout_width="fill_parent" android:layout_height="fill_parent" 

and also removed

android:layout_weight ="1" 

This worked fine. Thanks to @TechEnd

Comments

1

Simply you have to change in Scrollview Property like as below :

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true" android:background="#f7f7f7" android:layout_weight="1" android:orientation="vertical" android:padding="25dp" > 

Comments

1

From Manifest for this Activity Remove : "android:windowSoftInputMode="adjustPan"

It Will Work Surely.

1 Comment

Please see a solution might help stackoverflow.com/a/59549588/3904109
0

You need to close your

< ScrollView> </ScrollView>

i don't see it or u just forget to post it ???

Comments

0
 <ScrollView android:layout_width="match_parent" android:layout_height="40dp" android:fadeScrollbars="false" android:scrollbarStyle="insideInset" android:scrollbarThumbVertical="@drawable/scrollview_thumb" android:scrollbarTrackVertical="@drawable/custom_scroll_style"> <EditText android:id="@+id/input_customer_email" android:layout_width="match_parent" android:layout_height="40dp" android:clickable="false" android:longClickable="false" android:focusable="false" android:inputType="textMultiLine" android:hint="Customer's Email Address" /> </ScrollView> 

1 Comment

Welcome to SO! When you reply to a question to a code, try to explain it a little bit. In this case there are 5 more answers so expose the Pros of yours.
0

In my case, the ListView will be holding an adapter for inflating a vertical stack of buttons. I've calculated and assigned the ListView height manually (in such a way that all buttons are expanded). The scrolling issue I had was, using ListView inside the ScrollView (where the scrolling happen, If I click outside the ListView's bounds and try to scroll. Whereas the scrolling won't happen, if I try to scroll by clicking inside the ListView's bounds). I went through multiple stackoverflow answers/android docs and also tried few custom ListView/LinearLayout (with adapter) but in the end nothing worked. Then, I understood the logic and made the ListView to have NestedScrolling implementation and it worked like charm.

I just made this change to my code

myListView.setNestedScrollingEnabled(true); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.