查询描述:我使用透明主题的自定义进度对话框。这工作正常。我面临的问题是,当我的键盘打开时,如果我显示自定义进度对话框,然后它强制关闭我的键盘。但是,如果我使用默认的进度对话框,那么它工作正常。自定义进度对话框隐藏软键盘android
:正如您所看到的,即使进度对话框出现后键盘仍然存在。 我想在自定义进度对话框中实现相同的功能。
:正如您所看到的,当对话框显示时,键盘会消失。每次用户必须打开键盘时,感觉都很乏味。
这里是我的代码:
public class CustomProgressDialog extends Dialog {
private ImageView imageView;
private Context mContext;
public CustomProgressDialog(Context context) {
super(context, R.style.DialogTheme);
mContext = context;
getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
WindowManager.LayoutParams wlmp = getWindow().getAttributes();
wlmp.gravity = Gravity.CENTER_HORIZONTAL;
getWindow().setAttributes(wlmp);
setTitle(null);
setCancelable(true);
//setOnCancelListener(null);
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(200, 200);
imageView = new ImageView(context);
imageView.setBackgroundResource(R.drawable.custom_dialog);
layout.addView(imageView, params);
addContentView(layout, params);
}
@Override
public void show() {
super.show();
AnimationDrawable frameAnimation = (AnimationDrawable) imageView.getBackground();
frameAnimation.start();
}
@Override
public void dismiss() {
super.dismiss();
}
}
对话主题style.xml:
<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">@color/actionbar_gradient_endColor</item>
</style>
任何帮助将不胜感激。
<EditText android:id="@+id/et_search_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/imgClearSearch"
android:background="@drawable/rounded_rdt_txt"
android:hint="Search here..."
android:layout_centerVertical="true"
android:singleLine="true" />
@YvetteColomb:没有我在清单中设置的任何IME选项。 而对于EDITTEXT这里是: <的EditText 机器人:ID = “@ + ID/et_search_category” 机器人:layout_width = “match_parent” 机器人:layout_height = “WRAP_CONTENT” 机器人:layout_toLeftOf =“@ + ID/imgClearSearch” 机器人:背景= “@绘制/ rounded_rdt_txt” 机器人:提示= “搜索这里......” 机器人:layout_centerVertical = “真” 机器人:单线= “真” /> –
我不知道现在有时间运行并测试一些东西。如果它仍然在周二,我会写一个答案(我真的很忙atm) –
无忧@YvetteColomb。感谢您宝贵的时间。 :) –