How to position underline Text in React Native? - css

How can I add border with some margin or padding ? I want to remove the extended underline broder on left side of details text The underline should be only below text Details how can I position it correctly ? I tried marginLeft and paddingLeft is not working. Code:
<TouchableOpacity>
<View style={styles.underlineTextContainer}>
<Text style={styles.imgText}>DETAILS</Text>
</View>
</TouchableOpacity>
underlineTextContainer: {
borderBottomWidth: 2,
borderColor: '#ffffff'
}
imgText: {
fontFamily: Fonts.SourceSansProBold,
fontSize: 16,
fontWeight: "bold",
fontStyle: "normal",
lineHeight: 16,
letterSpacing: 0,
color: "#ffffff",
paddingLeft: 25,
paddingBottom: 5,
textAlign: 'center'
}
Applying above code gives me this:
But I want something like this:

instead of giving paddingLeft: 25 on your text component's style give margin Left on the parent View component like this:
underlineTextContainer: {
borderBottomWidth: 2,
borderColor: '#ffffff',
marginLeft: 25,
}
imgText: {
fontFamily: Fonts.SourceSansProBold,
fontSize: 16,
fontWeight: "bold",
fontStyle: "normal",
lineHeight: 16,
letterSpacing: 0,
color: "#ffffff",
paddingBottom: 5,
textAlign: 'center'
}

Related

How can i increase height of my content view without messing with message button?

How can i make my view long? i want that the content view increases its height till the Message button
So how can i do that? you can see the image how its currenlty looking i tried to increase paddingVertical but than message button is also going down side and not even visible, i want that view make its height still the message button without messing with message button how to do that?
import { StyleSheet, Text, View, Image } from 'react-native'
import React from 'react'
import { formHead } from '../CommonCss/FormCss'
const GetUser = () => {
const data = [
{
username: 'hello',
image: 'img',
}
]
return (
<View style={styles.container}>
<View style={styles.content}>
<Image source={{ uri: data[0].image }} style={styles.userimg} />
<Text style={styles.namesty}>{data[0].username}</Text>
</View>
<Text style={styles.formbtn}>Message</Text>
<Text style={styles.formbtn2}>Message</Text>
</View>
)
}
export default GetUser
const styles = StyleSheet.create({
container: {
width: '100%',
height: '100%',
backgroundColor: 'black'
},
formbtn: {
width: '80%',
backgroundColor: 'white',
borderRadius: 10,
borderColor: 'white',
borderWidth: 1,
fontSize: 25,
color: 'black',
textAlign: 'center',
paddingVertical: 10,
marginVertical: 10,
fontWeight: "bold",
top: '50%',
marginLeft: 35
},
formbtn2: {
width: '80%',
backgroundColor: 'white',
borderRadius: 10,
borderColor: 'white',
borderWidth: 1,
fontSize: 25,
color: 'black',
textAlign: 'center',
paddingVertical: 10,
marginVertical: 10,
fontWeight: "bold",
top: '30%',
marginLeft: 35
},
namesty: {
color: 'white',
fontWeight: 'bold',
fontSize: 30,
margin: 10,
backgroundColor: '#111111',
paddingVertical: 10,
paddingHorizontal: 20,
borderRadius: 20,
},
userimg: {
width: 150,
height: 150,
borderRadius: 75,
},
content: {
backgroundColor: '#111111',
paddingVertical: 20,
paddingHorizontal: 20,
borderRadius: 20,
width: '100%',
alignItems: 'center',
}
})
I hope this will work for you, update this stylesheet:
const styles = StyleSheet.create({
container: {
width: '100%',
height: '100%',
backgroundColor: 'black'
},
formbtn: {
width: '80%',
backgroundColor: 'white',
borderRadius: 10,
fontSize: 25,
color: 'black',
textAlign: 'center',
height: 50,
paddingVertical: 10,
fontWeight: "bold",
// top: '50%',
position: 'absolute',
marginLeft: 35,
bottom: 15+50+15
},
formbtn2: {
width: '80%',
backgroundColor: 'white',
borderRadius: 10,
fontSize: 25,
color: 'black',
textAlign: 'center',
height: 50,
paddingVertical: 10,
fontWeight: "bold",
// top: '30%',
position: 'absolute',
marginLeft: 35,
bottom: 15
},
namesty: {
color: 'white',
fontWeight: 'bold',
fontSize: 30,
margin: 10,
backgroundColor: '#111111',
paddingVertical: 10,
paddingHorizontal: 20,
borderRadius: 20,
},
userimg: {
width: 150,
height: 150,
borderRadius: 75,
},
content: {
backgroundColor: '#444',
paddingVertical: 20,
paddingHorizontal: 20,
borderRadius: 20,
width: '100%',
alignItems: 'center',
height: height-50-50-15-15-15
}
})
In content and container style add flex:1
return (
<View style={styles.container}>
<View style={styles.content}>
<ScrollView>
<Image source={{ uri: data[0].image }} style={styles.userimg} />
<Text style={styles.namesty}>{data[0].username}</Text>
</ScrollView>
</View>
<View>
<Text style={styles.formbtn}>Message</Text>
<Text style={styles.formbtn2}>Message</Text>
</View>
</View>
)
content: {
flex:1,
backgroundColor: '#111111',
paddingVertical: 20,
paddingHorizontal: 20,
borderRadius: 20,
width: '100%',
alignItems: 'center',
}

Create a backdrop in react native

I have a bottom bar to which i want to add this kind of background in react native currently it looks like this.
How do i achieve this
This is my current code
<View style={{justifyContent: 'center', alignItems: 'center'}}>
<Image
style={tabStyle.iconSize}
source={require('../assets/List-icon-1.png')}
/>
<Image
style={tabStyle.arrowSize}
source={require('../assets/Arrow-1-1.png')}
/>
</View>
const tabStyle = StyleSheet.create({
iconSize: {
height: 35,
width: 35,
marginBottom: 5,
},
arrowSize: {
height: 17,
width: 15,
marginBottom: 5,
},
});
You need a component for this.
Using Yarn
yarn add react-native-linear-gradient
Using Npm
npm install react-native-linear-gradient --save
after that
import LinearGradient from 'react-native-linear-gradient';
// Within your render function
<LinearGradient colors={['#4c669f', '#3b5998', '#192f6a']} style={styles.linearGradient}>
<Text style={styles.buttonText}>
Sign in with Facebook
</Text>
</LinearGradient>
// Later on in your styles..
var styles = StyleSheet.create({
linearGradient: {
flex: 1,
paddingLeft: 15,
paddingRight: 15,
borderRadius: 5
},
buttonText: {
fontSize: 18,
fontFamily: 'Gill Sans',
textAlign: 'center',
margin: 10,
color: '#ffffff',
backgroundColor: 'transparent',
},
});
if doesnt work u can commet for help ^^
You can customize this in tabBar options prop in your tabBar component
tabBarOptions={{
activeTintColor: '#fff',
inactiveTintColor: '#fff',
activeBackgroundColor: 'transparent',
inactiveBackgroundColor: '#fff',
style: {
backgroundColor: '#white',
}
}}
>

React Native - elevation shadow not covering all View

My View's shadow not covering all the outside but just the top and the bottom:
Here is the style:
root: {
borderRadius: 20,
elevation: 5,
paddingTop: 22,
paddingHorizontal: 20,
paddingBottom: 20,
marginTop: 16,
borderWidth: 0,
backgroundColor: '#ffffff',
}
How can I make the shadow to cover all the View?
You should give marginHorizonal in your root style.

React native elevation - shadow appears in boarder

I tried to add a shadow using the following code:
<View style={{alignItems: 'center'}}>
<View
style={{
width: '95%',
borderWidth: 1,
elevation: 5,
shadowColor: 'black',
shadowRadius: 10,
}}>
<TextInput
style={{
borderColor: colors.primary,
borderWidth: 1,
color: 'black',
fontSize: 18,
height: 64,
}}
onChange={input => this.onChange(input.nativeEvent.text)}
value={this.state.input}
/>
<View>{this.state.results}</View>
</View>
</View>
Somehow, the elevation effects the width and hight of the inner "box":
When I use elevation: 10:
When I use elevation: 0:
How can I set the shadow to be outside the boarder?
After a lot of testing, I figured out the problem was that there's no backgroundColor applied to the View with the shadow.
Now the shadow seems to work as expected

native base card height not adjusting

I have a card with 2 tabs inside. If one tab has more text than the other the height of the taller tab will be forced on to the shorter tab. Ideally, each card would have a fixed height and on more content, it would add a scroll bar instead of expanding the whole card.
Card code:
<Card style={HomeStyles.card}>
<Tabs initialPage={0} tabBarUnderlineStyle={{ backgroundColor: 'orange' }} onChangeTab={({ i }) => this.tabChanged(i)}>
<Tab heading={
<TabHeading style={{ backgroundColor: '#1f1e1e' }}>
<Icon type={this.props.iconType} name={this.props.iconName} style={HomeStyles.cardHeaderIcon} />
<Text>{this.props.tabName}</Text>
</TabHeading>} style={HomeStyles.cardBody}>
{this.props.mainTab}
</Tab>
<Tab heading={
<TabHeading style={{ backgroundColor: '#1f1e1e' }}>
<Icon type="FontAwesome" name="info-circle" style={HomeStyles.cardHeaderInfoTabIcon} />
<Text>Info</Text>
</TabHeading>} style={HomeStyles.cardBody}>
{this.props.infoTab}
</Tab>
</Tabs>
</Card>
// And styles
const HomeStyles = StyleSheet.create({
card: {
flex: 1,
marginLeft: 10,
marginRight: 10,
marginTop: 15,
marginBottom: 20,
borderRadius: 1,
borderWidth: 2,
borderColor: BackgroundColor,
},
cardHeader: {
backgroundColor: BackgroundColor,
height: 15
},
cardHeaderIcon: {
fontSize: 15,
color: '#ffa31a'
},
cardHeaderText: {
color: '#fff',
fontSize: 15,
},
cardHeaderInfoTabIcon: {
fontSize: 15,
color: '#70fff7'
},
cardBody: {
borderColor: '#ffa31a',
backgroundColor: BackgroundColor,
},
cardBodyText: {
alignItems: 'center',
color: '#fff',
fontSize: 12
},
cardButton: {
height: 25,
width: 100,
margin: 5, alignSelf: "center"
}
});

Resources