亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

鍵盤隱藏BottomSheetDialog

鍵盤隱藏BottomSheetDialog

MMTTMM 2021-10-13 13:33:48
我正在使用BottomSheetDialog從客戶那里獲取一些輸入,當用戶單擊TextInputLayout時,我的視圖包含TextInputLayout和TextInputLayout下方的按鈕,下面的按鈕被鍵盤隱藏,所以我需要鍵盤上方的那個按鈕,嘗試了很多可能性,但是無法修復它。附上有關它的照片。Java文件(活動)代碼:BottomSheetDialog customTipAmountBottomSheetDialog;private void showCustomTipAmountBottomSheet() {    customTipAmountBottomSheetDialog = new BottomSheetDialog(OrderActivity.this);    View customTipAmountBottomSheetView = getLayoutInflater().inflate(R.layout.custom_tip_amount_bottom_sheet, null);    customTipAmountBottomSheetDialog.setContentView(customTipAmountBottomSheetView);    InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);    assert imm != null;    imm.showSoftInput(binding.invoiceDialog.submit, InputMethodManager.RESULT_HIDDEN);    TextInputLayout customTipAmountBSTIL = customTipAmountBottomSheetView.findViewById(R.id.customTipAmountBSTIL);    EditText customTipAmountBSET = customTipAmountBottomSheetView.findViewById(R.id.customTipAmountBSET);    ImageView submit_custom_tip_amount = customTipAmountBottomSheetView.findViewById(R.id.submit_custom_tip_amount);    submit_custom_tip_amount.setOnClickListener(view -> {        String amount = customTipAmountBSET.getText().toString();        if (amount.length() > 0 && Integer.parseInt(amount) > 0) {            int tipAmount = Integer.parseInt(amount);            if (tipAmount > 0 && tipAmount < 51) {                binding.invoiceDialog.customTipAmountTv.setText(tipAmount);                captainTipAmount = tipAmount;                customTipAmountBottomSheetDialog.dismiss();            } else {                customTipAmountBSTIL.setError("Amount should be less than 50");            }        } else {            customTipAmountBSTIL.setError("Requires a valid amount");        }    });    customTipAmountBottomSheetDialog.show();}
查看完整描述

2 回答

?
慕妹3242003

TA貢獻1824條經驗 獲得超6個贊

在您的活動 java 類中的 onCreate() 方法上使用以下方法。

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

幾天前,我遇到了同樣的問題。然后在我的onCreate()方法中使用這部分代碼,那么問題就解決了。

樣本:

http://img1.sycdn.imooc.com//61666ffc00014e2200020023.jpg

查看完整回答
反對 回復 2021-10-13
?
qq_遁去的一_1

TA貢獻1725條經驗 獲得超8個贊

有幾種方法可以實現這一點:

1.將以下代碼寫入您的 Android Manifest 文件中的<activity>標簽下:

android:windowSoftInputMode="stateHidden|adjustResize"

2.將以下代碼寫入您onCreate()的活動方法中:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

我希望它對你有用。


查看完整回答
反對 回復 2021-10-13
  • 2 回答
  • 0 關注
  • 243 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號