Diálogo en Android KitKat parece ser cortado


Utilicé el tema de diálogo para una actividad y funciona bien en Android

diálogo android 4.4 problema

Falta la parte superior del diseño. Puedes ver que los límites parecen estar cortados.

Estoy usando un emulador de Android para probar la aplicación, por lo que no se si el problema se debe a la máquina virtual o a alguna otra razón.

Author: Hacketo, 2013-11-21

6 answers

Puede resolver el problema que se cortará desde el código inferior.

dialog.getWindow().setFlags(
    WindowManager.LayoutParams.FLAG_FULLSCREEN, 
    WindowManager.LayoutParams.FLAG_FULLSCREEN);
 36
Author: Mu-ik Jeon,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-29 08:40:18

Debe extender el Diálogo y en el onCreate llamar al siguiente método:

@TargetApi(14)
public void toggleHideBar() {

    if (Build.VERSION.SDK_INT < 18) {
        return;
    }

    // The UI options currently enabled are represented by a bitfield.
    // getSystemUiVisibility() gives us that bitfield.
    int uiOptions = getWindow().getDecorView().getSystemUiVisibility();
    int newUiOptions = uiOptions;
    boolean isImmersiveModeEnabled =
            ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
    if (isImmersiveModeEnabled) {
        Log.d("dialog", "Turning immersive mode mode off.");
    } else {
        Log.d("dialog", "Turning immersive mode mode on.");
    }

    // Status bar hiding: Backwards compatible to Jellybean
    if (Build.VERSION.SDK_INT >= 16 && (newUiOptions & View.SYSTEM_UI_FLAG_FULLSCREEN) <= 0) {
        newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
    }

    // Immersive mode: Backward compatible to KitKat.
    // Note that this flag doesn't do anything by itself, it only augments the behavior
    // of HIDE_NAVIGATION and FLAG_FULLSCREEN.  For the purposes of this sample
    // all three flags are being toggled together.
    // Note that there are two immersive mode UI flags, one of which is referred to as "sticky".
    // Sticky immersive mode differs in that it makes the navigation and status bars
    // semi-transparent, and the UI flag does not get cleared when the user interacts with
    // the screen.
    if (Build.VERSION.SDK_INT >= 18 && (newUiOptions & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) <= 0) {
        newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }

    getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
}
 9
Author: Ronen A.,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-03-18 21:24:20

Finalmente, traté de hacer algo con el nuevo modo Inmersivo de pantalla completa disponible en Android 4.4. Android FullScreen

Simplemente ponga esto en el onResume de la actividad "dialog" , y eso le permite usar diálogos en una actividad de pantalla completa, sin el corte superior:)

Editar: Se ha añadido una comprobación de compatibilidad para la versión de destino, setSystemUiVisibility se implementa en Api 11, pero parece que necesita que "parche" solo para Android 4.4)

// Only for Api >=4.0 
if (android.os.Build.VERSION.SDK_INT >= 16) {
    int mUIFlag = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // I removed this
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LOW_PROFILE
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; // and this to keep the navigation bar
    getWindow().getDecorView().setSystemUiVisibility(mUIFlag);
}
 3
Author: Hacketo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-12-13 12:59:26

Tengo un problema similar, pero con el uso de un diálogo personalizado. Desafortunadamente, no pude publicar mi captura de pantalla aquí.

Probé con algunas opciones diferentes, y parece que ejecutar la actividad principal en modo de pantalla completa afecta esto. Si elimino el siguiente código, el diálogo parece funcionar bien.

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

Me di cuenta de esto después de obtener la actualización 4.4 KitKat en un Google Nexus 7 (primera versión). Además, no parece hacer una diferencia si tengo el título del diálogo presente o ni.

 1
Author: Tuomas Tikka,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-25 09:23:56

Simplemente agregue esta línea de código en el método onCreate de su actividad.

GetWindow().setFlags (0x04000000, 0x04000000); / / FLAG_TRANSLUCENT_STATUS

 0
Author: bigbugbb,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-28 03:38:09

Tuve exactamente el mismo problema que describe y muestra en sus capturas de pantalla. El problema ocurrió solo en KitKat.

En mi caso sucedió en algunos cuadros de diálogo que usaban un estilo personalizado. El siguiente es un estilo que reproduce el problema cuando se aplica a un diálogo. Observe la primera línea, que tiene el atributo parent="android.Theme " , al eliminar ese atributo, el problema se resolvió.

<style name="transparent_low_dim" parent="android:Theme">
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">true</item>
    <item name="android:backgroundDimAmount">0.3</item>
    <item name="android:windowAnimationStyle">@null</item>
</style>

Para arreglarlo, eliminé el atributo padre para que la primera línea se viera ahora como el siguiente:

<style name="transparent_low_dim">
 0
Author: PerracoLabs,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-01-15 16:30:48