NestedScrollView is not scrolling due to Editext

谁说胖子不能爱 提交于 2019-12-09 03:07:30

I had a similar issue. The Design Support Library is a great lib, but it's a bit buggy at the moment. You can find some issues regarding NestedScrollView here: NestedScrollView Issues. We will have to wait for the next updates until we have a fully working lib.

Until then, you can try some alternative libs, such as: ObservableScrollView.

It is pretty simple to use:

1 - Add the dependency to your build.gradle file:

repositories {
    mavenCentral()
}

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

2 - In your Layout, declare the ObservableScrollView like:

<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 - In your Activity, implement ObservableScrollViewCallbacks:

public class MainActivity extends AppCompatActivity
  implements ObservableScrollViewCallbacks {

4 - Implement the required 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 - Example on showing/hiding the ActionBar on scrolling the 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 it helps.

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!