android彈出提示框,android 朋友圈彈出框,Android popupwidown?實現朋友圈評論彈窗顯示在軟鍵盤上面

 2023-12-01 阅读 20 评论 0

摘要:布局:android:layout_width="match_parent"android:layout_height="wrap_content"android:focusable="true"android:focusableInTouchMode="true"android:background="@color/color_f4f4f5">andro

布局:

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:focusable="true"

android:focusableInTouchMode="true"

android:background="@color/color_f4f4f5">

android:id="@+id/popup_circle_comment_edit"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:textSize="?text_size_normal"

android:layout_marginTop="8dp"

android:clickable="true"

android:enabled="true"

android:layout_marginBottom="8dp"

android:layout_marginStart="10dp"

android:textColor="@color/color_303133"

android:padding="6dp"

android:layout_toStartOf="@+id/popup_circle_comment_send"

android:background="@drawable/shape_radius5_white"/>

android:id="@+id/popup_circle_comment_send"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:textColor="@color/color_606266"

android:textSize="?text_size_normal"

android:text="發送"

android:paddingTop="6dp"

android:paddingBottom="6dp"

android:paddingStart="10dp"

android:paddingEnd="10dp"

android:layout_alignParentEnd="true"

android:layout_marginEnd="8dp"

android:layout_marginStart="8dp"

android:layout_centerVertical="true"

android:background="@drawable/edit_layout_bg"/>

初始化popupwidown

PopupWindow commentPopup = new PopupWindow(popupBinding.getRoot(), ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

commentPopup.setTouchable(true);

commentPopup.setFocusable(true);

commentPopup.setOutsideTouchable(true);//點擊彈窗外彈窗消失

commentPopup.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);//顯示在軟鍵盤上面配置

commentPopup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);//顯示在軟鍵盤上面配置

commentPopup.showAtLocation(popupBinding.getRoot(), Gravity.BOTTOM, 0, 0);

showSoft();

/**

* 彈出輸入法窗口

*/

private void showSoft() {

Handler handle = new Handler();

handle.postDelayed(new Runnable() {

@Override

public void run() {

//設置可獲得焦點

popupCircleCommentEdit.setFocusable(true); //popupCircleCommentEdit

popupCircleCommentEdit.setFocusableInTouchMode(true);

//請求獲得焦點

popupCircleCommentEdit.requestFocus();

InputMethodManager inputMethodManager = (InputMethodManager)

popupCircleCommentEdit.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

inputMethodManager.showSoftInput(popupCircleCommentEdit, 0);//彈出時強制讓輸入框popupCircleCommentEdit獲取焦點

}

}, 200);//延遲彈出

}

本文地址:https://blog.csdn.net/wang670144941/article/details/107932586

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/3/186968.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息