Cod*_*joy 33 android dialog views
我有这个很好的对话框视图我将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>
Run Code Online (Sandbox Code Playgroud)
我想让我的对话框出现,但背景不会淡出.这可能吗?导致调用此对话框的视图具有neato背景我希望将其显示为对话框的背景.
我在网上发现了这个:
<style name="doNotDim" parent="@android:style/Theme.Dialog">
<item name="android:backgroundDimAmount">0</item>
</style >
Run Code Online (Sandbox Code Playgroud)
但不知道如何将其应用于我的对话框?我有一个叫做的课public class UserInputDialog extends Dialog implements OnClickListener.它将其内容视图设置为上述布局.
我想我正在这样做,只是不知道如何添加这种风格,所以我不能淡化背景.
次要问题:您是否可以通过使用主题在对话框中获得新的外观(通过显示带有文字的图像或图标)?
小智 164
您还可以使用以下代码删除代码的暗淡效果:
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
Run Code Online (Sandbox Code Playgroud)
Rob*_*ond 33
创建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>
Run Code Online (Sandbox Code Playgroud)
并将主题应用于您的活动.
<activity android:name=".SampleActivity" android:theme="@style/Theme.DoNotDim">
Run Code Online (Sandbox Code Playgroud)
创建自定义样式并将其放在值文件夹中
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="YourCustomStyle" parent="android:Theme">
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
要将样式设置为您可以使用的单个对话框
Dialog dialog = new Dialog(context, R.style.YourCustomStyle);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
26123 次 |
| 最近记录: |