how to set react native button to full width

react native full width
react native button height
react-native width fit content
react-native height auto
react native elements
native-base button width
react native button background color
gradient button in react native

I have tried all of the examples out there but I can not figure it out. I am using this https://github.com/xinthink/react-native-material-kit

If I use the dimensions as the width the button width goes off screen. I would like if possible to have the logo at the very top and the form and button at the very button. this is for android only.

 const btnStyle = {
btn: {
    flex: 1,
    flexDirection: "row"
    //resizeMode: 'cover'
}
};
const ColoredRaisedButton = MKButton.coloredButton()
.withStyle(btnStyle.btn)
.build();

<ScrollView style={styles.scrollView}>
<View style={styles.container}>
    {/* Here the magic happens*/}
    <View style={styles.cardStyle}>
        <Image
            source={require("./../img/logo_login.jpg")}
            style={styles.cardImageStyle}
        />
        <View style={styles.cardContentStyle}>
            <Form
                ref="form"
                type={User}
                onChange={this.onChange.bind(this)}
                value={this.state.value}
                options={options}
            />
        </View>
        <View style={styles.cardActionStyle}>
            <ColoredRaisedButton>
                <Text pointerEvents="none" style={styles.buttonText}>
                    BUTTON
                </Text>
            </ColoredRaisedButton>
        </View>
    </View>
</View>
</ScrollView>;

const styles = {
cardStyle: {
    flex: 1,
    backgroundColor: "#ffffff",
    borderRadius: 2,
    borderColor: "#ffffff",
    borderWidth: 1,
    shadowColor: "rgba(0,0,0,.12)",
    shadowOpacity: 0.8,
    shadowRadius: 2,
    alignItems: "center",
    flexDirection: "column",
    justifyContent: "center",
    shadowOffset: {
        height: 1,
        width: 2
    }
},
cardImageStyle: {
    flex: 1,
    height: 170,
    flexDirection: "row",
    resizeMode: "cover"
},
cardContentStyle: {
    padding: 15 //,
    // bottom:0,
    // position:'absolute',
    //justifyContent: 'flex-end'
},
cardActionStyle: {
    flex: 1,
    borderStyle: "solid",
    borderTopColor: "rgba(0,0,0,.1)",
    borderTopWidth: 1,
    padding: 15,
    alignItems: "center",
    flexDirection: "column",
    justifyContent: "center"
},
scrollView: {
    flex: 1
},
container: {
    flex: 1,
    alignItems: "stretch",
    backgroundColor: "#eae9e9",
    padding: 20 //,
    //position:'absolute'
},
buttonText: {
    fontSize: 14,
    fontWeight: "bold",
    color: "white"
}
};

You should remove the alignItems: 'center' from both cardStyle & cardActionStyle, then you should get a full width button.

Full width button w/ flex-box in react-native, I came here looking for the same question. Having experimented further, I've found the simplest way is to use alignSelf: 'stretch' . This forces the  Here we are going to provide complete information for react native button component. You may have been observed when you are trying to set button width and height of react native button, then it will not expand as per the mentioned width and height. So Here we are going to provide solution for the same issue.

You can use this pattern:

<View style={[{width:"100%"}]}>
    <Button
        onPress={this.closeModal}
        title="Close"
        color="#841584"
        style={[{borderRadius: 5,}]}
        hardwareAccelerated
    />
</View> 

How to set <Button> 100% width? · Issue #587 · react-native , I had an issue with setting full screen width for the button, meaning i had a problem with the left margin. This is how i solved the issue: import{Button} from '​react-  In React Native you can achieve it using a Button inside a View and set the width of View import { View, Button } from "react-native"; <View style={{ width: 200}}><Button title="Login"/></View> usamaabrar22 commented Dec 19, 2019 @engrrbilal You are right.

Set Button Width and Height In React Native Lets use the below source that helps to set width and height of button. Here you need to specify the button width and height parameter in view layout.

<View style={[{ width: "90%", margin: 10, backgroundColor: "red" }]}>
   <Button
      onPress={this.buttonClickListener}
      title="Button Three"
      color="#90A4AE"
    />
</View>

How To Customize Button In React Native, Set Button Width and Height In React Native. Lets use the below source that helps to set width and height of button. Here you need to specify the  I am learning react native programming for android mobile apps. I am making a screen where I need to set height of button. I have added button in view and set the height of using style however there is no change on button height.

React Native Button Width Fit To Content, Use the below layout design to create button. Apply the below stylesheet design. /** * Sample React Native App * https://github.com/facebook/  As of React Native 0.42 height: and width: accept percentages.. Use width: 80% in your stylesheets and it just works.. Screenshot. Live Example Child Width/Height as Proportion of Parent

Height and Width · React Native, The general way to set the dimensions of a component is by adding a fixed width and height to style. All dimensions in React Native are unitless, and represent  A component's height and width determine its size on the screen. The simplest way to set the dimensions of a component is by adding a fixed width and height to style. All dimensions in React Native are unitless, and represent density-independent pixels. Setting dimensions this way is common for components that should always render at exactly

How to set button width and height in React Native?, It often happens that we want to change the dimensions of the button, which by default is extended to the entire width of the parent element. A basic button component that should render nicely on any platform. Supports a minimal level of customization. If this button doesn't look right for your app, you can build your own button using TouchableOpacity or TouchableNativeFeedback. For inspiration, look at the source code for this button component.

Comments
  • almost perfect! it works for the button but then it messes up the image. any ideas how to do both
  • Still waiting for an answer to this one... lol...