gpt4 book ai didi

android - 自定义对话框在 android 7.1.1 上工作错误

转载 作者:行者123 更新时间:2023-11-30 00:16:09 25 4
gpt4 key购买 nike

嗨,我在 android 中使用自定义对话框,我的代码:

public void generarDialogoParametros(String titulo, boolean llamaNumero) {
Dialog dialogo = new Dialog(context,R.style.AlertDialogTheme);
dialogo.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialogo.setContentView(R.layout.dialogo_parametros);
dialogo.setTitle(titulo);
TextView spo2 = (TextView) dialogo.findViewById(R.id.editTextSPO2);
TextView pulsobajo = (TextView) dialogo.findViewById(R.id.editTextPulsoAlto);
TextView pulsoalto = (TextView) dialogo.findViewById(R.id.editTextPulsoBajo);
Button guardar = (Button) dialogo.findViewById(R.id.btnAceptarParametros);
Button cancelar = (Button) dialogo.findViewById(R.id.btnCancelarParametros);
spo2.setText(preferencias.getSPO2() + "");
pulsoalto.setText(preferencias.getPulsoAlto() + "");
pulsobajo.setText(preferencias.getPulsoBajo() + "");
guardarParametrosNuevos(guardar,cancelar, dialogo, spo2, pulsoalto, pulsobajo, llamaNumero);
dialogo.show();
dialogo.setCancelable(false);
}

在 android 4,5,6 中的工作方式如下:

enter image description here

但在 7+

enter image description here

我不知道,我如何修复它可以帮助我?

最佳答案

尝试使用以下代码以编程方式设置对话框的高度和宽度

    public void generarDialogoParametros(String titulo, boolean llamaNumero) {
Dialog dialogo = new Dialog(context,R.style.AlertDialogTheme);
dialogo.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialogo.setContentView(R.layout.dialogo_parametros);
Window window = dialogo.getWindow();
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
window.setGravity(Gravity.CENTER);
dialogo.setTitle(titulo);
TextView spo2 = (TextView) dialogo.findViewById(R.id.editTextSPO2);
TextView pulsobajo = (TextView) dialogo.findViewById(R.id.editTextPulsoAlto);
TextView pulsoalto = (TextView) dialogo.findViewById(R.id.editTextPulsoBajo);
Button guardar = (Button) dialogo.findViewById(R.id.btnAceptarParametros);
Button cancelar = (Button) dialogo.findViewById(R.id.btnCancelarParametros);
spo2.setText(preferencias.getSPO2() + "");
pulsoalto.setText(preferencias.getPulsoAlto() + "");
pulsobajo.setText(preferencias.getPulsoBajo() + "");
guardarParametrosNuevos(guardar,cancelar, dialogo, spo2, pulsoalto, pulsobajo, llamaNumero);
dialogo.show();
dialogo.setCancelable(false);
}

关于android - 自定义对话框在 android 7.1.1 上工作错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47257187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com