反复原生的浮动动作按钮

Pan*_*kur 19 floating-action-button react-native

我想在屏幕右下角的native native android中使用浮动操作按钮.但我无法这样做.

所述CreateButton成分含有浮动按钮的代码.我在List View之后调用了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>
Run Code Online (Sandbox Code Playgroud)

Pan*_*kur 28

使用底部,左侧,右侧,顶部调整按钮,并为按钮提供绝对位置.

这是我用来制作浮动按钮的代码

width: 60,  
height: 60,   
borderRadius: 30,            
backgroundColor: '#ee6e73',                                    
position: 'absolute',                                          
bottom: 10,                                                    
right: 10, 
Run Code Online (Sandbox Code Playgroud)

  • 不起作用,绝对位置在 Android 中不起作用。 (2认同)

Hit*_*ahu 16

<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>
Run Code Online (Sandbox Code Playgroud)

安装图标包:https://github.com/oblador/react-native-vector-icons

npm install react-native-vector-icons --save

反应本地链接


小智 8

看看这个组件,我认为它正是你正在寻找的:https: //github.com/mastermoo/react-native-action-button

  • 项目未维护 (3认同)