React Native Android - 我如何*停止* <view>&#39; s在Modal中自动调整大小?

时间:2017-02-10 00:32:49

标签: android react-native

RN的

版本是0.41.2

有没有人知道如何停止查看使用flexbox进行大小调整,自动&#34;缩小&#34;如果在其中一个视图中使用TextInput元素,它们的高度是多少?通过示例可能更容易说明,并且要清楚,您可以看到这些是嵌套在<Modal>内的View。

这是没有键盘打开时的视图。两者都相同。

enter image description here

这是TextInput具有焦点时会发生什么。我不希望这些视图在键盘上方调整。我希望黄色和蓝色的视图保持全尺寸&#39; - 完全如iOS屏幕截图所示。

在iOS上,相同的代码不会移动/调整视图(在键盘上方)。这也是我在Android上想要的行为。

enter image description here

以下是示例呈现方法代码。它只是一个标准的模板RN项目,它改变了渲染方法来测试它。

我尝试将android:windowSoftInputMode="adjustNothing"插入AndroidManifest.xml但没有效果。我确定它只是道具或其他明显设置。希望有人能让我知道吗?

render() {
 return (
  <View style={styles.container}>
     <Modal
        animationType={'slide'}
        transparent={false}
        onRequestClose={() => console.log('sd')}
     >
        <View style={{flex:1, backgroundColor: 'lightgrey'}}>

           <View style={{
              //height:300, 
              flex: 1, 
              backgroundColor: 'yellow',
              alignItems: 'center', 
              justifyContent: 'center',
           }}>
                 <View style={{
                    margin: 10,
                    //height:100, 
                    width: 200,
                    justifyContent: 'center',
                    backgroundColor: 'green'}}>
                    <TextInput style={{height: 40, backgroundColor: 'orange'}}     />

                 </View>
           </View>

           <View style={{
                 //height:200, 
                 flex: 1,
                 backgroundColor: 'blue', 
           }}>

           </View>
        </View>
     </Modal>
  </View>
  );
 }

2 个答案:

答案 0 :(得分:1)

Did you try wrapping all of the contents within a ScrollView and then a child KeyboardAvoidingView?

答案 1 :(得分:0)

我遇到了完全相同的问题,没有在各处添加2018-08-05 11:23:12 - PayPal Express debug (Call data): {"METHOD":"SetExpressCheckout","MAXAMT":183,"RETURNURL":"http:\/\/localhost:8888\/opencart_test\/index.php?route=extension\/payment\/pp_express\/checkoutReturn","CANCELURL":"http:\/\/localhost:8888\/opencart_test\/index.php?route=checkout\/checkout","REQCONFIRMSHIPPING":0,"NOSHIPPING":1,"LOCALECODE":"EN","LANDINGPAGE":"Login","HDRIMG":null,"PAYFLOWCOLOR":"","CHANNELTYPE":"Merchant","ALLOWNOTE":"0","PAYMENTREQUEST_0_SHIPPINGAMT":"","PAYMENTREQUEST_0_CURRENCYCODE":"USD","PAYMENTREQUEST_0_PAYMENTACTION":"Sale","L_PAYMENTREQUEST_0_DESC0":"","L_PAYMENTREQUEST_0_NAME0":"iMac","L_PAYMENTREQUEST_0_NUMBER0":"Product 14","L_PAYMENTREQUEST_0_AMT0":100,"L_PAYMENTREQUEST_0_QTY0":"1","L_PAYMENTREQUEST_0_ITEMURL0":"http:\/\/localhost:8888\/opencart_test\/index.php?route=product\/product&product_id=41","L_PAYMENTREQUEST_0_ITEMWEIGHTVALUE0":"5.00","L_PAYMENTREQUEST_0_ITEMWEIGHTUNIT0":"kg","L_PAYMENTREQUEST_0_NUMBER1":"tax","L_PAYMENTREQUEST_0_NAME1":"Eco Tax (-2.00)","L_PAYMENTREQUEST_0_AMT1":2,"L_PAYMENTREQUEST_0_QTY1":1,"L_PAYMENTREQUEST_0_NUMBER2":"tax","L_PAYMENTREQUEST_0_NAME2":"VAT (20%)","L_PAYMENTREQUEST_0_AMT2":20,"L_PAYMENTREQUEST_0_QTY2":1,"PAYMENTREQUEST_0_ITEMAMT":"122.00","PAYMENTREQUEST_0_AMT":"122.00"} 2018-08-05 11:23:14 - PayPal Express debug (Result): "TOKEN=EC%2d20P06488EN6017601&TIMESTAMP=2018%2d08%2d05T11%3a23%3a14Z&CORRELATIONID=289d80aadc967&ACK=Success&VERSION=109%2e0&BUILD=47733884" 2018-08-05 11:23:35 - PayPal Express debug (Call data): {"METHOD":"GetExpressCheckoutDetails","TOKEN":"EC-20P06488EN6017601"} 2018-08-05 11:23:36 - PayPal Express debug (Result): "TOKEN=EC%2d20P06488EN6017601&BILLINGAGREEMENTACCEPTEDSTATUS=0&CHECKOUTSTATUS=PaymentActionNotInitiated&TIMESTAMP=2018%2d08%2d05T11%3a23%3a36Z&CORRELATIONID=881526a4938a&ACK=Success&VERSION=109%2e0&BUILD=47733884&EMAIL=sandboxkoh%2dbuyer%40gmail%2ecom&PAYERID=RDSJX9J569WC6&PAYERSTATUS=verified&FIRSTNAME=test&LASTNAME=buyer&COUNTRYCODE=SG&ADDRESSSTATUS=Confirmed&CURRENCYCODE=USD&AMT=122%2e00&ITEMAMT=122%2e00&SHIPPINGAMT=0%2e00&HANDLINGAMT=0%2e00&TAXAMT=0%2e00&INSURANCEAMT=0%2e00&SHIPDISCAMT=0%2e00&INSURANCEOPTIONOFFERED=false&L_NAME0=iMac&L_NAME1=Eco%20Tax%20%28%2d2%2e00%29&L_NAME2=VAT%20%2820%25%29&L_NUMBER0=Product%2014&L_NUMBER1=tax&L_NUMBER2=tax&L_QTY0=1&L_QTY1=1&L_QTY2=1&L_TAXAMT0=0%2e00&L_TAXAMT1=0%2e00&L_TAXAMT2=0%2e00&L_AMT0=100%2e00&L_AMT1=2%2e00&L_AMT2=20%2e00&L_ITEMWEIGHTVALUE0=5%2e0&L_ITEMWEIGHTUNIT0=kg&PAYMENTREQUEST_0_CURRENCYCODE=USD&PAYMENTREQUEST_0_AMT=122%2e00&PAYMENTREQUEST_0_ITEMAMT=122%2e00&PAYMENTREQUEST_0_SHIPPINGAMT=0%2e00&PAYMENTREQUEST_0_HANDLINGAMT=0%2e00&PAYMENTREQUEST_0_TAXAMT=0%2e00&PAYMENTREQUEST_0_INSURANCEAMT=0%2e00&PAYMENTREQUEST_0_SHIPDISCAMT=0%2e00&PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID=sandbox%2dfacilitator%40firstcom%2ecom%2esg&PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&L_PAYMENTREQUEST_0_NAME0=iMac&L_PAYMENTREQUEST_0_NAME1=Eco%20Tax%20%28%2d2%2e00%29&L_PAYMENTREQUEST_0_NAME2=VAT%20%2820%25%29&L_PAYMENTREQUEST_0_NUMBER0=Product%2014&L_PAYMENTREQUEST_0_NUMBER1=tax&L_PAYMENTREQUEST_0_NUMBER2=tax&L_PAYMENTREQUEST_0_QTY0=1&L_PAYMENTREQUEST_0_QTY1=1&L_PAYMENTREQUEST_0_QTY2=1&L_PAYMENTREQUEST_0_TAXAMT0=0%2e00&L_PAYMENTREQUEST_0_TAXAMT1=0%2e00&L_PAYMENTREQUEST_0_TAXAMT2=0%2e00&L_PAYMENTREQUEST_0_AMT0=100%2e00&L_PAYMENTREQUEST_0_AMT1=2%2e00&L_PAYMENTREQUEST_0_AMT2=20%2e00&L_PAYMENTREQUEST_0_ITEMLENGTHVALUE0=5%2e0&L_PAYMENTREQUEST_0_ITEMLENGTHUNIT0=kg&PAYMENTREQUESTINFO_0_ERRORCODE=0" 2018-08-05 11:23:36 - PayPal Express debug (Call data): {"TOKEN":"EC-20P06488EN6017601","PAYERID":"RDSJX9J569WC6","METHOD":"DoExpressCheckoutPayment","PAYMENTREQUEST_0_NOTIFYURL":"http:\/\/localhost:8888\/opencart_test\/index.php?route=extension\/payment\/pp_express\/ipn","RETURNFMFDETAILS":1,"PAYMENTREQUEST_0_SHIPPINGAMT":"","PAYMENTREQUEST_0_CURRENCYCODE":"USD","PAYMENTREQUEST_0_PAYMENTACTION":"Sale","L_PAYMENTREQUEST_0_DESC0":"","L_PAYMENTREQUEST_0_NAME0":"iMac","L_PAYMENTREQUEST_0_NUMBER0":"Product 14","L_PAYMENTREQUEST_0_AMT0":100,"L_PAYMENTREQUEST_0_QTY0":"1","L_PAYMENTREQUEST_0_ITEMURL0":"http:\/\/localhost:8888\/opencart_test\/index.php?route=product\/product&product_id=41","L_PAYMENTREQUEST_0_ITEMWEIGHTVALUE0":"5.00","L_PAYMENTREQUEST_0_ITEMWEIGHTUNIT0":"kg","L_PAYMENTREQUEST_0_NUMBER1":"tax","L_PAYMENTREQUEST_0_NAME1":"Eco Tax (-2.00)","L_PAYMENTREQUEST_0_AMT1":2,"L_PAYMENTREQUEST_0_QTY1":1,"L_PAYMENTREQUEST_0_NUMBER2":"tax","L_PAYMENTREQUEST_0_NAME2":"VAT (20%)","L_PAYMENTREQUEST_0_AMT2":20,"L_PAYMENTREQUEST_0_QTY2":1,"PAYMENTREQUEST_0_ITEMAMT":"122.00","PAYMENTREQUEST_0_AMT":"122.00"} 2018-08-05 11:23:38 - PayPal Express debug (Result): "TIMESTAMP=2018%2d08%2d05T11%3a23%3a37Z&CORRELATIONID=410f3f87c7c4e&ACK=Failure&VERSION=109%2e0&BUILD=47733884&L_ERRORCODE0=12200&L_SHORTMESSAGE0=Buyer%20ID%20not%20given%20for%20ImmediatePay%20transaction%2e&L_LONGMESSAGE0=Buyer%20ID%20not%20given%20for%20ImmediatePay%20transaction%2e&L_SEVERITYCODE0=Error" ,而是在ScrollView中做了一些改动: 而不是:AndroidManifest.xml 我写道:android:windowSoftInputMode="adjustResize"

对我来说就像一个魅力