Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native Elements Input full width

I was trying to implement the Input from React Native Elements, which is the blue one. I want to make the Input have full width within the red view. So I did

width: '100%', marginHorizontal: 0, padding: 0, and alignItems: 'stretch' independently.

But none of them didn't work. What is the problem? This is the screenshot of the screen

https://i.sstatic.net/NDhuC.png

And this is the corresponding code

    <View style = {styles.campusInputView}>
      <Input
        containerStyle = {styles.campusInputContainer}
        inputStyle = {styles.campusInput}
        placeholder = 'KAIST'
        editable = {false}
      />
    </View>

with the style

  campusInputView: {
    borderWidth: 1,
    borderColor: 'red',
    position: 'absolute',
    top: height * 100 / 640,
    left: width * 45 / 360,
    width: width * 270 / 360,
  },
  campusInputContainer: {
    borderWidth: 1,
    borderColor: 'green',
    alignItems: 'stretch',
  },
  campusInput: {
    borderWidth: 1,
    borderColor: 'blue',
    flex: 1,
    fontFamily: 'NanumSquareB',
    fontSize: 20,
    paddingVertical: 0,
  },
like image 444
TonyWild Avatar asked Sep 12 '25 19:09

TonyWild


2 Answers

Overwriting paddingHorizontal of containerStyle as 0 makes the input full width. Overwriting only padding as 0 is not enough.

import { Input } from 'react-native-elements'

<Input
  containerStyle = {{ paddingHorizontal: 0 }}
  // other settings
/>
like image 97
asukiaaa Avatar answered Sep 14 '25 11:09

asukiaaa


You should add paddingHorizontal: 0 to campusInputContainer

campusInputContainer: {
  borderWidth: 1,
  borderColor: 'green',
  alignItems: 'stretch',
  paddingHorizontal: 0
},
like image 27
Paweł Łukaszewicz Avatar answered Sep 14 '25 11:09

Paweł Łukaszewicz