【发布时间】:2020-09-23 06:37:18
【问题描述】:
我想检测使用的是什么设备,为此我想使用 Expo-device。 我想设置屏幕,以便当使用的设备是平板电脑时,屏幕左侧是一个组件,右侧是另一个组件(我想将屏幕拆分为 66.66% 左侧和 33.33% 右侧)。
我如何设置一个条件来说明如果设备是平板电脑我希望屏幕处于横向模式并在屏幕左侧添加一个组件?
如果有人可以帮助我完成不同的步骤,那就太好了,因为我有点迷茫。
非常感谢。
例如,假设当我使用 iphone 或 android 手机时,我有这个(这将是平板电脑上的正确组件):
<ImageBackground
source={require("../../assets/images/background.jpg")}
style={styles.backgroundImage}
>
<Header
backgroundImage={require("../../assets/images/bg-header.png")}
centerComponent={{
text: i18n.t("about.title"),
style: styles.headerComponentStyle
}}
placement="center"
containerStyle={styles.headerContainerStyle}
statusBarProps={{ barStyle: "light-content" }}
/>
<ScrollView style={styles.containerScroll}>
<Text style={styles.h3}>{i18n.t("terms.title")}</Text>
<Text style={styles.h5terms}>{i18n.t("terms.content")}</Text>
<View style={styles.container}>
<TouchableOpacity
style={styles.touchable2}
onPress={() => this.props.navigation.navigate("Settings")}
>
<View style={styles.view2}>
<Text style={styles.textimg2}>
{i18n.t("signup.action.back")}
</Text>
</View>
<Image
source={require("../../assets/images/btn-background.png")}
style={styles.tripsimg2}
/>
</TouchableOpacity>
</View>
<Text>{"\n\n"}</Text>
</ScrollView>
</ImageBackground>
);
}
}
【问题讨论】:
-
您可以查看此链接,这将有助于解决React native check if tablet or screen in inches
-
感谢您抽出宝贵时间回答,我去看看这个。
标签: react-native tablet