Home > Web Front-end > JS Tutorial > body text

How to implement floating buttons in React Native

php中世界最好的语言
Release: 2018-05-02 11:02:10
Original
2645 people have browsed it

This time I will show you how to implement floating buttons in React Native. What are the precautions for implementing floating buttons in React Native? The following is a practical case, let's take a look.

React Native Suspension

Button Group Parts: react-native-action-button, pure JS component, supports Android and IOS dual platforms, supports setting sub-buttons, supports custom position and style, and icon.

Rendering

Installation method

npm i react-native-action-button --save
react-native link react-native-vector-icons
Copy after login
Because the react-native-vector-icons icon component is used, a link needs to be made. If you have already used react-native-vector-icons in your project, this step is not required.

Sample code

<View style={styles.container}>
  <Text style={styles.welcome}>
   悬浮按钮组件示例
  </Text>
  <ActionButton buttonColor="rgba(231,76,60,1)" position=&#39;left&#39; verticalOrientation=&#39;up&#39;>
   <ActionButton.Item buttonColor=&#39;#9b59b6&#39; title="New Task" onPress={() => console.log("notes tapped!")}>
   <Icon name="ios-create-outline" style={styles.actionButtonIcon} />
   </ActionButton.Item>
   <ActionButton.Item buttonColor=&#39;#3498db&#39; title="Notifications" onPress={() => {}}>
   <Icon name="ios-notifications-off" style={styles.actionButtonIcon} />
   </ActionButton.Item>
   <ActionButton.Item buttonColor=&#39;#1abc9c&#39; onPress={() => {}}>
   <Icon name="ios-done-all-outline" style={styles.actionButtonIcon} />
   </ActionButton.Item>
  </ActionButton>
  <ActionButton
   buttonColor="rgba(231,76,60,1)"
   onPress={() => { alert('你点了我!')}}
   renderIcon={() => (<View style={styles.actionButtonView}><Icon name="ios-create-outline" style={styles.actionButtonIcon} />
   <Text style={styles.actionButtonText}>新增</Text>
   </View>)}
  />
  </View>
Copy after login

Main parameter description

ActionButton

  1. size: The size of the button, the default is 56

  2. active: Whether to display the button

  3. position: The position of the button, which can be left center right

  4. offsetX: The offset position on the X axis

  5. offsetY : Offset position on the Y axis

  6. onPress : Click

    event

  7. onLongPress : Long press event

  8. buttonText: Button title

  9. verticalOrientation: The direction of the pop-up button, up or down

  10. renderIcon: Yes Customize the button display style. The default is a plus sign

ActionButton.Item

  1. size: the size of the button , the default is 56

  2. title: button title

  3. buttonColor: button color

  4. onPress: Click event

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Recommended reading:

Detailed explanation of webpack mobile terminal automated build rem steps

Angular5 step instructions for adding style class to component tags

The above is the detailed content of How to implement floating buttons in React Native. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!