我有这个非常漂亮的对话框视图,我设置了我的UserInputDialog
类为:
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/nameMessage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="What is your name Captain?"
>
</TextView>
<EditText
android:id="@+id/nameEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
>
</EditText>
<LinearLayout android:id="@+id/LinearLayout02" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<Button
android:id="@+id/okButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK">
</Button>
<Button android:id="@+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel">
</Button>
</LinearLayout>
</LinearLayout>
我想要让我的对话框能显示出来,但是这个背景颜色不变暗。这个可能么?用这个视图调用的对话框有一个neato背景,我想要作为对话框的背景显示出来
我在网上找到了这个:
<style name="doNotDim" parent="@android:style/Theme.Dialog">
<item name="android:backgroundDimAmount">0</item>
</style >
但是我不知道怎么把它应用到我的对话框中?我有一个类调用了公共类UserInputDialog,继承对话框实现OnClickListener。它给上边的布局描述设置文本视图。
我想我这么做是对的,只是不知道怎么把这个加到样式上,因为我不想让背景颜色变浅。
创建一个res/values/styles.xml
文件,然后把这个加到下边这里
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.DoNotDim" parent="android:Theme">
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
然后把这个主题应用到你的activity
<activity android:name=".SampleActivity" android:theme="@style/Theme.DoNotDim">
通过下边的代码你可以移除掉昏暗的效果
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);