我有一个活动,点击按钮我显示自定义的对话框。但是,当打开对话框时,屏幕的像素会混乱。我想显示对话框全屏以下是我的代码。
final Dialog contactDialog = new Dialog(SettingsInformationActivity.this,R.style.DialogTheme);
contactDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
contactDialog.setContentView(R.layout.contact_dialog);
contactDialog.show();
自定义对话框XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="10dp" >
<EditText
android:id="@+id/emailid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/email_id"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/emailsubject"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/email_subject"
android:inputType="textEmailSubject" />
<EditText
android:id="@+id/message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/email_message"
android:inputType="textMultiLine"
android:lines="3" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<com.buzzreel.custom.HelveticaTextView
android:id="@+id/send"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:background="@drawable/round_rect_shape"
android:padding="10dp"
android:text="@string/send"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
<com.buzzreel.custom.HelveticaTextView
android:id="@+id/cancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:background="@drawable/round_rect_shape"
android:padding="10dp"
android:text="@string/cancel"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
</LinearLayout>
适用于全屏的样式:
<style name="DialogTheme" parent="android:Theme.Dialog">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<!-- No backgrounds, titles or window float -->
<item name="android:windowBackground">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
</style>
每当对话框打开时,这都搞砸了如下:
答案 0 :(得分:0)
我认为问题可能是由于这一行<item name="android:windowBackground">@null</item>
。尝试删除它,它应该工作。