2013-09-04 1 views
0

내 안드로이드 프로젝트에서 액티비티 XML 파일에 배경 이미지를 추가했습니다. 또한 제목 표시 줄을 맨 위에 표시하지 않도록 스타일을 설정했습니다. 이 활동에는 버튼을 누르면 대화 상자가 표시됩니다.활동에 대한 배경 이미지를 설정하면 Android 대화 상자의 너비가 실제로 작아 집니까?

최근 이미지를 추가하고 제목 표시 줄을 표시하지 않도록 설정 한 다음 테스트 해보고 버튼을 클릭하면 대화 상자의 너비가 100px와 비슷합니다. 배경 이미지를 추가하기 전에 대화 상자의 너비가 적당하고 부모를 채 웁니다.

<?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="[email protected]" /> 

     <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> 

사람이 여기에 무슨 잘못 알고 있나요 :

이는 XML 대화 상자 사용에 대한 파일은?

편집 :

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

가 어떻게 제목 표시 줄을 제거하고 여전히 대화의 폭 정상 폭을 만들 수 있습니다

그것이 그 문제의 원인?

답변

0

이 시도 감사 : 버전 22에서

//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(); 
+0

이 나에게 전체 화면 대화 상자를 표시했다, 그래서 나는 _Theme_Material_Light_Dialog_ 테마 변형을 사용하여 문제가 해결되었다. 테마 변경 힌트 주셔서 감사합니다. :) – devrique

관련 문제