I am trying to add FloatingActionButton
on right bottom side of the screen. I am using this library http://www.material-ui.com/#/components/floating-action-button
import React, { Component } from "react";
import logo from "./logo.svg";
import "./App.css";
import AppBar from "material-ui/AppBar";
import FloatingActionButton from "material-ui/FloatingActionButton";
import MuiThemeProvider from "material-ui/styles/MuiThemeProvider";
import * as strings from "./Strings";
import styles from "./Styles";
import ContentAdd from "material-ui/svg-icons/content/add";
const AppBarTest = () =>
<AppBar
title={strings.app_name}
iconClassNameRight="muidocs-icon-navigation-expand-more"
/>;
class App extends Component {
render() {
return (
<MuiThemeProvider>
<div>
<AppBarTest />
<FloatingActionButton style={styles.fab}>
<ContentAdd />
</FloatingActionButton>
</div>
</MuiThemeProvider>
);
}
}
export default App;
Styles.js
const style = {
fab: {
backgroundColor: '#000000'
},
};
export default style;
It is showing FloatingActionButton
on top-left side, I want to make this on right-bottom side. What is the way to do this ?
Why style is not applying on FloatingActionButton
?
The button should be placed in the bottom right corner of the screen. The recommended margin for the bottom is 16dp for phones and 24dp for tablets. In the example above, 16dp was used. The actual drawable size should be 24dp according to the Google design specs.
Add the floating action button to your layoutThe size of the FAB, using the app:fabSize attribute or the setSize() method. The ripple color of the FAB, using the app:rippleColor attribute or the setRippleColor() method. The FAB icon, using the android:src attribute or the setImageDrawable() method.
A floating action button (FAB) is a circular button that triggers the primary action in your app's UI. This page shows you how to add the FAB to your layout, customize some of its appearance, and respond to button taps.
Inside the Bottom app, the bar adds the bottom Navigation View and adds the menu items that we created in the last step. Add the Floating action button. Below is the code for the activity_main.xml file.
Step 1: Open your Terminal and run the below command. It will install Expo CLI globally in your system. Step 2: Now, create a new React Native Project by running the below command. Step 3: You’ll be asked to choose a template. Select blank template. Step 4: Create a new file called FAB.js, This file is a custom component to create a FAB button.
1 Change the root layout to Coordinator Layout 2 Add Bottom App bar. 3 Inside the Bottom app, the bar adds the bottom Navigation View and adds the menu items that we created in the last step. 4 Add the Floating action button.
Try this style:
const fabStyle = {
right: 20,
position: 'fixed'
};
and later u use margin, top... but don't use auto on position: fixed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With