簡體   English   中英

使組件適合屏幕,無滾動 React-native

[英]Fit component to screen, No scrolling React-native

我有兩個組件的圖像和視圖,我試圖將兩者都放在屏幕上,但它會溢出,我不想實現 scrollView。

問題是 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>

這是它的結果在此處輸入圖像描述

查找設備屏幕的高度。

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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM