加上两句就好了:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
项目中代码:
public class VedioReplyMessageFragment extends BottomSheetDialogFragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dialog_reply_message, container, false);
ButterKnife.bind(this, view);
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ScreenUtils.getScreenHeight(getActivity()) / 3 * 2));
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
return view;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
mBean = (VideoMessageBean.ListEntity) getArguments().getSerializable("bean");
//头像
GlideHelper.getInstance().loadImage(getActivity(),mBean.getUserImg(),mIvAvatar,R.mipmap.ic_unlogin_avatar);
//用户名
if (!TextUtils.isEmpty(mBean.getNickName())) {
mTvName.setText("@" + mBean.getNickName());
}
//时间
if (!TextUtils.isEmpty(mBean.getCreateTime())){
mTvDate.setText( DateHelper.formatDetailTimeData(Long.valueOf(mBean.getCreateTime())));
}
//内容
if (!TextUtils.isEmpty(mBean.getContent())) {
mTvComment.setText(mBean.getContent());
}
if (mBean!=null && !TextUtils.isEmpty(mBean.getNickName())){
mEdtComment.setHint("@"+mBean.getNickName());
}else{
mEdtComment.setHint("回复点好听的吧~");
}
mBusId = mBean.getBusId();
parentId = mBean.getCommentId();
mNewMainLoader = new NewMainLoader();
initListener();
}
/**
* 点击事件
*/
private void initListener() {
mIvClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
mEdtComment.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
if (keyCode == KeyEvent.KEYCODE_ENTER && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm.isActive(view)) {
imm.hideSoftInputFromWindow(view.getApplicationWindowToken(), 0);
}
//评论
String commentContent = mEdtComment.getText().toString().trim();
if (TextUtils.isEmpty(commentContent)) {
Toast.makeText(getActivity(), "请输入内容", Toast.LENGTH_SHORT).show();
} else {
getReply(commentContent);
}
return true;
}
return false;
}
});
}
/**
* 回复内容
* @param commentContent
*/
private void getReply(String commentContent) {
RxHelper.toSubscribe(mNewMainLoader.getVideoComment(mBusId,"COMMENT", commentContent,parentId), new LoadingSubscriber(getActivity()) {
@Override
protected void _onNext(Object o) {
if (o instanceof VedioCommentListBean.ListEntity) {
ToastUtils.showNormalShort(getActivity(),"回复成功");
dismiss();
}
}
@Override
protected void _onError(String msg, String errorCode, boolean isToast) {
if (errorCode.equals("103")){
ToastUtils.showNormalShort(getActivity(),"评论功能升级中");
}else{
super._onError(msg, errorCode, isToast);
}
dismiss();
}
}, true);
}
}
网友评论