我有兩個組件的影像和視圖,我試圖將兩者都適合螢屏,但它會溢位,我不想實作滾動視圖。
問題是 Google 登錄按鈕退出螢屏
這是我的方法
<KeyboardAwareScrollView
showsVerticalScrollIndicator={false}
style={{ backgroundColor: 'white' }}
resetScrollToCoords={{ x: 0, y: 0 }}
scrollEnabled={this.state.keyboardOpened}
>
<View style={{ backgroundColor: "white",flex:1}}>
<Image
style={{ width: "100%",height:200, backgroundColor: "white" }}
source={require('./assets/login.gif')}
resizeMode={"contain"}
/>
</View>
<View>
{this.renderLoginDetails()}
</View>
</KeyboardAwareScrollView>
這是它的結果

uj5u.com熱心網友回復:
找到設備螢屏的高度。
import { Dimensions } from 'react-native';
const windowHeight = Dimensions.get('window').height;
<KeyboardAwareScrollView
showsVerticalScrollIndicator={false}
style={{ backgroundColor: 'white' }}
resetScrollToCoords={{ x: 0, y: 0 }}
scrollEnabled={this.state.keyboardOpened}
>
<View style={{ backgroundColor: "white",flex:1, height: windowHeight*0.04}}>
<Image
style={{ width: "100%",height:200, backgroundColor: "white" }}
source={require('./assets/login.gif')}
resizeMode={"contain"}/>
</View>
<View style={{height: windowHeight*0.06}}>
{this.renderLoginDetails()}
</View>
</KeyboardAwareScrollView>
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/367845.html
