¿El ancho del cuadro de diálogo de Android se vuelve muy pequeño cuando configuro una imagen de fondo para una actividad?

In my android project, I added a background image to my activity xml file. As well I set the style to not show a title bar on top. This activity has a button that when pressed will show a dialog box.

Recently I just added the image and made it not show the title bar, then when I went to test it out, and then clicked the button, the dialog box width is like 100px. Before I added the background image, I the dialog box width is fine, it fills the parent.

This is the xml file for used for the dialog box:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/activity_vertical_margin"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textview_email"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@+string/email" />

        <EditText
            android:id="@+id/textinput_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="textEmailAddress"
            android:text="james.jn1981@gmail.com" />

        <TextView
            android:id="@+id/textview_password"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@+string/password" />

        <EditText
            android:id="@+id/textinput_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="textPassword"
            android:text="123" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/button_exit"
            style="@style/footer"
            android:background="@drawable/bg_footer"
            android:text="@+string/cancel" />

        <Button
            android:id="@+id/button_login"
            style="@style/footer"
            android:background="@drawable/bg_footer"
            android:text="@+string/ok" />

    </LinearLayout>

</LinearLayout>

¿Alguien sabe qué pasa aquí?

EDIT:

Its this that's causing the issue:

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

How can I remove the title bar and still make the dialog width normal width?

Muchas Gracias

preguntado el 04 de septiembre de 13 a las 02:09

1 Respuestas

Prueba esto:

    //Use android.R.style.Theme or Theme_light
    Dialog dialog = new Dialog(context, android.R.style.Theme_Light);            
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    //Whatever your layout file is
    dialog.setContentView(R.layout.MyCustomDialogLayout);    
    dialog.show();

Respondido el 04 de Septiembre de 13 a las 02:09

In version 22 this was showing me a fullscreen dialog, so I used the Theme_Material_Light_Dialog theme variant and the problem was solved. Thank you for the theme change hint. :) - devrique

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.