Setting a border for react native TextInput -
using react native 0.26,
my component this
const search = () => { return ( <view style={styles.backgroundimage}> <textinput style={styles.textinput} onchangetext={(text) => console.log(text)} placeholder={"enter search term"}/> </view> ) }
and styles :
const styles = stylesheet.create({ backgroundimage: { flex : 1, flexdirection: "column", justifycontent: 'center', alignitems: 'center' }, textinput: { justifycontent: "center", alignitems: "stretch", borderrightwidth: 30, borderleftwidth: 30, height: 50, bordercolor: "#ffffff", } })
the problems facing are
- the border right width , left width not seem have effect , placeholder text begins on left edge.
- the background of textinput "grey" same view's background. expecting white default, (feels transparent).
- with ios simulator how bring keyboard, set
returnkeytype
, see how keyboard looks (and have code ononsubmitediting
, test).
1 cannot declare specific border directly on textinput unless multiline enabled (for example borderleftwidth
not work unless multiline={true}
enabled borderwidth
work), can wrap textinput in view , give border.
inputcontainer: { borderleftwidth: 4, borderrightwidth: 4, height: 70 }, input: { height: 70, backgroundcolor: '#ffffff', paddingleft: 15, paddingright: 15 }
2 need declare backgroundcolor
textinput.
3 make native keyboard show up, need go simulator menu , disconnect hardware. go hardware -> keyboard -> connect hardware keyboard, toggle off.
[![enter image description here][2]][2]
Comments
Post a Comment