React Native 上的浮动操作按钮
floating action button on react native
我想在屏幕右下角的 React Native android 中使用浮动操作按钮。但是我做不到。
CreateButton 组件包含浮动按钮代码。我在列表视图之后调用了 CreateButton 组件,我想在 ListView android 组件上显示此按钮,透明覆盖并在右下角固定位置。
<DrawerLayoutAndroid
drawerWidth={300}
drawerPosition={DrawerLayoutAndroid.positions.Left}
renderNavigationView={() => navigationView}>
<View style={styles.navBar}>
<TouchableOpacity style={styles.menuIconButton}>
<Image style={styles.menuIcon} source={{uri : 'https://cdn1.iconfinder.com/data/icons/basic-ui-elements-plain/422/ 06_menu_stack-128.png'}}/>
</TouchableOpacity>
<Text style={styles.appName}>LifeMaker</Text>
<TouchableOpacity style={styles.smokeIconButton}>
<Image style={styles.smokeIcon} source={{uri : 'http://avtech.com/images/home/icons/Icon_Smoke_&_Fire.png'}}/>
</TouchableOpacity>
</View>
<ToolbarAndroid
title="AwesomeApp"
onActionSelected={this.onActionSelected}/>
<ListView
dataSource={this.state.dataSource}
renderRow={this._renderSmokeSignals}/>
<CreateButton/> //this is floating button component call
</DrawerLayoutAndroid>
//this is floating button component (<CreateButton>)
<View style={styles.createButton}>
<AccentColoredFab>
<Icon
name='ion|plus'
size={25}
color='#000000'
style={styles.icon}
/>
</AccentColoredFab>
</View>
您可以尝试一些事情
1.borderWidth=0px
2. 将最小 api 级别设置为 21.
调整按钮的底部、左侧、右侧、顶部,并为按钮提供绝对位置。
这是我用来制作浮动按钮的代码
width: 60,
height: 60,
borderRadius: 30,
backgroundColor: '#ee6e73',
position: 'absolute',
bottom: 10,
right: 10,
查看此组件,我认为它完全符合您的要求:
https://github.com/mastermoo/react-native-action-button
无需创建你的,你可以直接使用React Native Action Button它很容易集成到你的项目中。
<TouchableOpacity
style={{
borderWidth: 1,
borderColor: 'rgba(0,0,0,0.2)',
alignItems: 'center',
justifyContent: 'center',
width: 70,
position: 'absolute',
bottom: 10,
right: 10,
height: 70,
backgroundColor: '#fff',
borderRadius: 100,
}}
>
<Icon name='plus' size={30} color='#01a699' />
</TouchableOpacity>
安装图标包:https://github.com/oblador/react-native-vector-icons
npm install react-native-vector-icons --save
react-native link
我有同样的问题,我已经尝试过 Pankaj Thakur 的解决方案,但它并没有为我解决(FAB 仍然相对于 scrollList)。所以我使用 Top 属性 为我解决了这个问题。
以下是至今(2019 年 12 月)仍在维护的更多存储库:
https://github.com/santomegonzalo/react-native-floating-action
https://github.com/WrathChaos/react-native-floating-action-button
我想在屏幕右下角的 React Native android 中使用浮动操作按钮。但是我做不到。
CreateButton 组件包含浮动按钮代码。我在列表视图之后调用了 CreateButton 组件,我想在 ListView android 组件上显示此按钮,透明覆盖并在右下角固定位置。
<DrawerLayoutAndroid
drawerWidth={300}
drawerPosition={DrawerLayoutAndroid.positions.Left}
renderNavigationView={() => navigationView}>
<View style={styles.navBar}>
<TouchableOpacity style={styles.menuIconButton}>
<Image style={styles.menuIcon} source={{uri : 'https://cdn1.iconfinder.com/data/icons/basic-ui-elements-plain/422/ 06_menu_stack-128.png'}}/>
</TouchableOpacity>
<Text style={styles.appName}>LifeMaker</Text>
<TouchableOpacity style={styles.smokeIconButton}>
<Image style={styles.smokeIcon} source={{uri : 'http://avtech.com/images/home/icons/Icon_Smoke_&_Fire.png'}}/>
</TouchableOpacity>
</View>
<ToolbarAndroid
title="AwesomeApp"
onActionSelected={this.onActionSelected}/>
<ListView
dataSource={this.state.dataSource}
renderRow={this._renderSmokeSignals}/>
<CreateButton/> //this is floating button component call
</DrawerLayoutAndroid>
//this is floating button component (<CreateButton>)
<View style={styles.createButton}>
<AccentColoredFab>
<Icon
name='ion|plus'
size={25}
color='#000000'
style={styles.icon}
/>
</AccentColoredFab>
</View>
您可以尝试一些事情 1.borderWidth=0px 2. 将最小 api 级别设置为 21.
调整按钮的底部、左侧、右侧、顶部,并为按钮提供绝对位置。
这是我用来制作浮动按钮的代码
width: 60,
height: 60,
borderRadius: 30,
backgroundColor: '#ee6e73',
position: 'absolute',
bottom: 10,
right: 10,
查看此组件,我认为它完全符合您的要求: https://github.com/mastermoo/react-native-action-button
无需创建你的,你可以直接使用React Native Action Button它很容易集成到你的项目中。
<TouchableOpacity
style={{
borderWidth: 1,
borderColor: 'rgba(0,0,0,0.2)',
alignItems: 'center',
justifyContent: 'center',
width: 70,
position: 'absolute',
bottom: 10,
right: 10,
height: 70,
backgroundColor: '#fff',
borderRadius: 100,
}}
>
<Icon name='plus' size={30} color='#01a699' />
</TouchableOpacity>
安装图标包:https://github.com/oblador/react-native-vector-icons
npm install react-native-vector-icons --save
react-native link
我有同样的问题,我已经尝试过 Pankaj Thakur 的解决方案,但它并没有为我解决(FAB 仍然相对于 scrollList)。所以我使用 Top 属性 为我解决了这个问题。
以下是至今(2019 年 12 月)仍在维护的更多存储库:
https://github.com/santomegonzalo/react-native-floating-action
https://github.com/WrathChaos/react-native-floating-action-button