NestedScrollView not scrolling due to Editext

I ran into a problem when I have the following structure in a NestedScrollView.

Here is my xml file:

<android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/app_base_color" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:id="@+id/nested_view_editprofile" android:focusable="true" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/app_base_color" android:weightSum="3"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <TextView android:id="@+id/txtvEditProfileUserName" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.7" android:gravity="center" android:paddingBottom="10dp" android:paddingLeft="3dp" android:paddingTop="10dp" android:textColor="@color/orange" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="0.85" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingBottom="5dp" android:paddingTop="10dp" android:weightSum="2"> <TextView android:id="@+id/txvEditProfileEntertainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1.3" android:gravity="right" android:text="0" android:textColor="@color/orange" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.7" android:paddingLeft="3dp" android:singleLine="true" android:text="Entertainers" android:textColor="@color/cement_grey" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingBottom="10dp" android:paddingTop="5dp" android:weightSum="2"> <TextView android:id="@+id/txvEditProfileSpectator" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1.3" android:gravity="right" android:text="0" android:textColor="@color/orange" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.7" android:paddingLeft="3dp" android:singleLine="true" android:text="Spectators" android:textColor="@color/cement_grey" /> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1.15" android:gravity="center" android:orientation="vertical"> <ImageButton android:id="@+id/imgbtnEditProfileSpactate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:color/transparent" android:paddingBottom="5dp" android:paddingTop="10dp" android:src="@drawable/plus" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.7" android:gravity="center" android:paddingBottom="10dp" android:paddingLeft="3dp" android:text="SPACTATE" android:textColor="@color/orange" /> </LinearLayout> </LinearLayout> <TextView android:id="@+id/txtvcom" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/app_base_color" android:padding="10dp" android:textColor="@color/cement_grey" /> <TextView android:layout_height="wrap_content" android:layout_width="match_parent" android:text="Personal Information" android:textColor="@color/orange" android:background="@drawable/app_base_background"/> <com.customview.CustomEditext android:id="@+id/edtxEdtPrflName" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="Name" android:textColor="@color/cement_grey" android:inputType="textImeMultiLine" android:drawableLeft="@drawable/name" android:drawablePadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:enabled="true" android:focusableInTouchMode="true" /> <com.customview.CustomEditext android:id="@+id/edtxEdtPrflUserName" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="Username" android:textColor="@color/cement_grey" android:inputType="textImeMultiLine" android:drawableLeft="@drawable/username" android:drawablePadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:enabled="false" android:focusableInTouchMode="true" /> <com.customview.CustomEditext android:id="@+id/edtxEdtPrflBio" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="Bio" android:textColor="@color/cement_grey" android:inputType="textImeMultiLine" android:drawableLeft="@drawable/bio" android:drawablePadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:enabled="true" android:focusableInTouchMode="true" /> <com.customview.CustomEditext android:id="@+id/edtxEdtPrflDOB" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="Date of Birth" android:textColor="@color/cement_grey" android:inputType="date|textImeMultiLine" android:drawableLeft="@drawable/dob" android:drawablePadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:focusableInTouchMode="true" android:enabled="true" /> <com.customview.CustomEditext android:id="@+id/edtxEdtPrflGender" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="Gender" android:textColor="@color/cement_grey" android:inputType="textImeMultiLine" android:editable="false" android:drawableLeft="@drawable/gender" android:drawablePadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:enabled="false" android:focusableInTouchMode="true" /> <TextView android:layout_height="wrap_content" android:layout_width="match_parent" android:text="Private Information" android:textColor="@color/orange" android:background="@drawable/app_base_background"/> <com.customview.CustomEditext android:id="@+id/edtxEdtPrflEmail" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="Email" android:textColor="@color/cement_grey" android:inputType="textEmailAddress|textImeMultiLine" android:drawableLeft="@drawable/mail" android:drawablePadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:enabled="true" android:focusableInTouchMode="true" /> <com.customview.CustomEditext android:id="@+id/edtxEdtPrflPhone" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="Phone" android:textColor="@color/cement_grey" android:inputType="phone|textImeMultiLine" android:maxLength="10" android:drawableLeft="@drawable/phone" android:drawablePadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:enabled="false" android:focusableInTouchMode="true" /> </LinearLayout> </android.support.v4.widget.NestedScrollView> 

Now because of Editext, I can’t scroll my NestedScrollView for this, I use the solution below and work fine, but it prevents Softkeyboard from opening for any Editext.

 public class CustomEditext extends EditText { public CustomEditext(Context _Context){ super(_Context); } public CustomEditext(Context context, AttributeSet attrs){ super(context,attrs); } public CustomEditext(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override public boolean onTouchEvent(MotionEvent event) { super.onTouchEvent(event); return false; } } 
+1
source share
2 answers

I had a similar problem. The design support library is a great library, but at the moment it’s a bit buggy. Here you can find some problems regarding NestedScrollView: Problems with NestedScrollView . We will have to wait for the next updates until we have a fully working library.

Until then, you can try several alternative libraries, for example: ObservableScrollView .

It is quite simple to use:

1 - add the dependency to the build.gradle file:

 repositories { mavenCentral() } dependencies { // Other dependencies are omitted compile 'com.github.ksoichiro:android-observablescrollview:1.5.0' } 

2 - In the layout, declare ObservableScrollView as:

 <com.github.ksoichiro.android.observablescrollview.ObservableListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/list" android:layout_width="match_parent" android:layout_height="match_parent" /> 

3 - Implement ObservableScrollViewCallbacks in your activity:

 public class MainActivity extends AppCompatActivity implements ObservableScrollViewCallbacks { 

4 - Implement the necessary methods and play with them:

 @Override public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { } @Override public void onDownMotionEvent() { } @Override public void onUpOrCancelMotionEvent(ScrollState scrollState) { } 

5 - An example of showing / hiding an ActionBar when scrolling through a list:

 @Override public void onUpOrCancelMotionEvent(ScrollState scrollState) { ActionBar ab = getSupportActionBar(); if (scrollState == ScrollState.UP) { if (ab.isShowing()) { ab.hide(); } } else if (scrollState == ScrollState.DOWN) { if (!ab.isShowing()) { ab.show(); } } } 

Hope this helps.

+2
source

adding android:windowSoftInputMode="adjustResize" to the activity in the manifest file solved my problem.

Kosh20 was suggested here: https://code.google.com/p/android/issues/detail?id=182362&q=nestedscrollview&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

+1
source

All Articles