I Have screen contain an image and I want to take the full-size screen with header?
I just use position: "absolute"
but it's not working to wrap the header, and I can't use header: null
because I want the back button to appear!
so how can I handle this?
what I get
what I want
Thanks in advance.
I Have screen contain an image and I want to take the full-size screen with header?
I just use position: "absolute"
but it's not working to wrap the header, and I can't use header: null
because I want the back button to appear!
so how can I handle this?
what I get
what I want
Thanks in advance.
Share Improve this question asked Sep 24, 2019 at 1:18 DevASDevAS 8272 gold badges18 silver badges44 bronze badges 3-
How about
position: fixed; top: 0; left: 0
? – Yuan-Hao Chiang Commented Sep 24, 2019 at 1:50 - 1 position in react-native can't take "Fixed" as the value just "relative | absolute" @Yuan-HaoChiang – DevAS Commented Sep 24, 2019 at 1:58
- 1 Possible duplicate of What's the best way to add a full screen background image in React Native – Joy Biswas Commented Sep 24, 2019 at 2:13
3 Answers
Reset to default 5You can make header transparent for a specific screen by adding property headertransparent
Try this
static navigationOptions = {
headerTransparent: true,
};
Complete Sample code
import React from "react";
import { View, Dimensions, Image } from "react-native";
import { createAppContainer, createStackNavigator } from "react-navigation";
import { Text } from "react-native";
const { width } = Dimensions.get("window");
class HomeScreen extends React.Component {
static navigationOptions = {
title: "Home"
};
render() {
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<Text
style={{ padding: 20 }}
onPress={() => this.props.navigation.navigate("Detail")}
>
Send To Detail
</Text>
</View>
);
}
}
class DetailScreen extends React.Component {
static navigationOptions = {
headerTransparent: true,
headerTintColor: "#fff"
};
render() {
return (
<View style={{ flex: 1 }}>
<Image
style={{ width: width, height: 400 }}
source={{
uri:
"https://media.gettyimages./photos/different-types-of-food-on-rustic-wooden-table-picture-id861188910?s=2048x2048",
cache: "force-cache"
}}
/>
</View>
);
}
}
const AppNavigator = createStackNavigator({
Home: {
screen: HomeScreen
},
Detail: {
screen: DetailScreen
}
});
export default createAppContainer(AppNavigator);
App Demo
use this styling in header { position: 'absolute', zIndex: 100, top: 0, left: 0, right: 0, elevation: 0, shadowOpacity: 0, borderBottomWidth: 0 }
You need hide the header, if you are using react navigation, you can add the navigationOptions for add attributes for hide the header, like these lines.
static navigationOptions = {
headerShown: false
};
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745493338a4630084.html
评论列表(0条)