mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-07 22:40:55 +08:00
Added nestedScrollEnabled prop to scroll view for android
Summary: Nested scrolling in scrollViews, listViews and flatLists are enabled on iOS by default, but needs to be enabled manually on Android. This PR introduces a `nestedScrollEnabled` property to ScrollViews to support nested scrolling on Android 21 and above. Enabling nested scroll will resolve issues with coordinator layout in android and required to support a collapsing toolbar. Tested on the test app. We are also using this property in our app currently to support scrolling behaviour required by coordinator layouts. [ANDROID] [ENHANCEMENT] [ScrollView] - Added a prop to enable nested scrolling Closes https://github.com/facebook/react-native/pull/18299 Reviewed By: sahrens Differential Revision: D7256604 Pulled By: mdvacca fbshipit-source-id: fb8b7f1b5bed39837a2066db7f2a8798d52a3fd6
This commit is contained in:
committed by
Facebook Github Bot
parent
378da73201
commit
263d04d756
@@ -8,7 +8,9 @@
|
||||
package com.facebook.react.views.scroll;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
import com.facebook.react.uimanager.DisplayMetricsHolder;
|
||||
@@ -21,6 +23,7 @@ import com.facebook.react.uimanager.ViewProps;
|
||||
import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
import com.facebook.react.uimanager.annotations.ReactPropGroup;
|
||||
import com.facebook.yoga.YogaConstants;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
@@ -120,6 +123,11 @@ public class ReactHorizontalScrollViewManager
|
||||
view.setOverScrollMode(ReactScrollViewHelper.parseOverScrollMode(value));
|
||||
}
|
||||
|
||||
@ReactProp(name = "nestedScrollEnabled")
|
||||
public void setNestedScrollEnabled(ReactHorizontalScrollView view, boolean value) {
|
||||
ViewCompat.setNestedScrollingEnabled(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveCommand(
|
||||
ReactHorizontalScrollView scrollView,
|
||||
|
||||
@@ -9,6 +9,8 @@ package com.facebook.react.views.scroll;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
@@ -21,8 +23,9 @@ import com.facebook.react.uimanager.ViewProps;
|
||||
import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
import com.facebook.react.uimanager.annotations.ReactPropGroup;
|
||||
import com.facebook.yoga.YogaConstants;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* View manager for {@link ReactScrollView} components.
|
||||
@@ -121,6 +124,11 @@ public class ReactScrollViewManager
|
||||
view.setOverScrollMode(ReactScrollViewHelper.parseOverScrollMode(value));
|
||||
}
|
||||
|
||||
@ReactProp(name = "nestedScrollEnabled")
|
||||
public void setNestedScrollEnabled(ReactScrollView view, boolean value) {
|
||||
ViewCompat.setNestedScrollingEnabled(view, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Map<String, Integer> getCommandsMap() {
|
||||
return ReactScrollViewCommandHelper.getCommandsMap();
|
||||
|
||||
Reference in New Issue
Block a user