⚠️ 此代码仓已归档。新地址请访问 rntpc_react-native-view-overflow。| ⚠️ This repository has been archived. For the new address, please visit rntpc_react-native-view-overflow.
This library will be useful for React Native versions below v0.57. For v0.57 and beyond, React Native supports Android overflow natively from this commit.
The problem is that a parent View in Android will clip the content of children Views (react-native)
This solves the problem of Overflow on Android (check this https://github.com/facebook/react-native/issues/16951)
This could make code simpler, so you don't need to move some Components outside parents to make layout work
You can read more about the motivation and this package here https://medium.com/@sibelius/solving-view-overflow-in-android-reactnative-f961752a75cd
$ npm install react-native-view-overflow --save
$ npm install react-native-view-overflow --save
$ react-native link react-native-view-overflow
import ViewOverflow from 'react-native-view-overflow';
<ViewOverflow>
<ComponentToEnableOverflow />
</ViewOverflow>
To make this work with FlatList and related components you need to replace CellRendererComponent
with ViewOverflow
, for example:
<FlatList
data={this.state.data}
keyExtractor={item => item.id}
CellRendererComponent={ViewOverflow}
renderItem={({ item, index }) => (
<ViewOverflow style={styles.item}>
// item....
</ViewOverflow>
)}
/>
To make this work in place of an Animated.View
, you need to use Animated.createAnimatedComponent
to create an animatable version of ViewOverflow
. For example:
import ViewOverflow from 'react-native-view-overflow';
const AnimatedViewOverflow = Animated.createAnimatedComponent(ViewOverflow);
You can then use AnimatedViewOverflow
in place of Animated.View
.
android/app/src/main/java/[...]/MainApplication.java
import com.entria.views.RNViewOverflowPackage;
to the imports at the top of the filenew RNViewOverflowPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:include ':react-native-view-overflow'
project(':react-native-view-overflow').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-view-overflow/android')
android/app/build.gradle
: compile project(':react-native-view-overflow')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。