查询说明:我正在使用透明主题的自定义进度对话框。这很好用。我的问题是,当我的键盘打开时,如果显示自定义进度对话框,则会强制关闭我的键盘。然而,如果我使用默认进度对话框,则可以正常工作。
: 如您所见,即使进度对话框出现后,键盘仍在那里。我想在自定义进度对话框中实现同样的效果。
: 如您所见,当对话框显示时,键盘会消失。这很烦人,每次用户都必须打开键盘。
以下是我的代码:
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 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" />