Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Positioning something from the right

I am building an App on react native in which I want to be position something from right

   <View style={searchDrop}> 
             <TextInput
              style={textInput}
              placeholder="Search Coin"
              onChangeText={(text) => this.onSearch(text)} />
              <TouchableOpacity onPress={() => this.props.navigation.navigate("CurrencySelection")}>
                      <Text style={money}> <Icons name="money" size={35} color="#fbc02d" /> </Text>
              </TouchableOpacity>
            </View>

with following styles

textInput: { 
    width: "70%",
    height: 35,
    marginLeft: 5,
    marginRight: 5,
    borderWidth: 0,
    backgroundColor: "white",
    borderRadius: 15,
    textAlign: 'center'
  }, 

searchDrop: {
    paddingTop: 32,
    paddingBottom: 5,
    display: "flex",
    flexDirection: "row",
    height: 80,
    backgroundColor: "#3b5998",
    width: 100%
  }, 
  money: {
    position: "absolute",
    right: 0
  }

With That I was expecting

<Text style={money}> <Icons name="money" size={35} color="#fbc02d" /> </Text>

To be on the absolute right side of the screen

Here is how it is looking now

enter image description here

like image 866
anny123 Avatar asked Nov 07 '22 01:11

anny123


1 Answers

Simply do this, it will move the icon to right.

  <View style={styles.searchDrop}>
    <TextInput
      style={styles.textInput}
      placeholder="Search Coin"
      onChangeText={text => this.onSearch(text)}
    />
    <TouchableOpacity
      style={styles.money}
      onPress={() => this.props.navigation.navigate('CurrencySelection')}>
          <Text> <Icons name="money" size={35} color="#fbc02d"/> </Text>
    </TouchableOpacity>
  </View>
like image 189
Haider Ali Avatar answered Nov 14 '22 23:11

Haider Ali