Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling android dialog without it fading the background

I have this nice dialog view I set my UserInputDialog class to:

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

I want my dialog to show up but for the background to not fade out. Is this possible? Cause the view that calls this dialog has a neato background I would like to be shown as a backdrop to the dialog.

I found this online:

<style name="doNotDim" parent="@android:style/Theme.Dialog">     <item name="android:backgroundDimAmount">0</item> </style > 

but not sure how to apply that to my dialog? I have a class called public class UserInputDialog extends Dialog implements OnClickListener. It sets its content view to the layout described above.

I think I am doing this all right, just not sure how to add that style so I can NOT fade the background.

Secondary question: Can you get new looks on your dialog (by say having an image or icon display with your text there) by using Themes?

like image 303
Codejoy Avatar asked Jun 24 '10 20:06

Codejoy


People also ask

How do I stop dialog close on click outside Android?

Simply, alertDialog. setCancelable(false); prevent user from click outside of Dialog Box.

How do I stop alert dialog closing?

AlertDialog dialog = (AlertDialog) getDialog(); dialog. getButton(AlertDialog. BUTTON_POSITIVE). setEnabled(false);

How do you dismiss dialog with click on outside of dialog?

You can use dialog. setCanceledOnTouchOutside(true); which will close the dialog if you touch outside of the dialog.

What is a dialogue in Android?

A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed. Dialog Design.


1 Answers

You can also remove the dim effect by code with the following:

dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); 
like image 174
Andrewx2 Avatar answered Sep 30 '22 03:09

Andrewx2