Creating a Dialog with dimmed background - android

I've created a Dialog that appears when a button is clicked. I made a custom layout for it and coded it like this:
final Dialog dialog = new Dialog (CheckpointsActivity.this, android.R.style.Theme_Translucent);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.alert_continue);
//rest of the code...
This is how the Dialog looks now:
And this is how I want it to look like:
It should be a lot darker in the background with a gradient effect. I can't seem to find any info on how to achieve this.

You can make a dialog box with the same background and gradient and then make the ui on top of that.

Related

display a view when an activity starts

I need to display a certain view when an activity starts, and when the user click ckecked to dismiss the view. It look like this
:
Has anyone an idea how can I do this? Any idea is welcome.
Yes, you can use a custom dialog
just create a custom XML and inflate it into your dialog object
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.custom_dialog);
dialog.show();
and then dismiss it by calling dialog.dismiss();
create custom dialog using below link and open it when activity starts...
you need to increase the margin to proivde more spaces
Have a look at custom dialog examples -
custom dialog 1
custom dialog 2
yes, you can use PopupWindow for Creating window
see these tutorila for adding PopupWindow in your Activity:
Using the PopupWindow class in Android apps
Example of using PopupWindow
You could use a RelativeLayout for this. When the user clicks check, the visibility of the 'upper' layout must be set to GONE.

Android: create a dialog with transparent background, no border and shade

I want to create a dialog with transparent BG and no border.
For this I use android.R.style.Theme_Translucent_NoTitleBar.
But in the dialog I have UI componenets - imageview and edittext.
I want these to create a shade over the activity page. Like the regular dialog is doing.
Any ideas how?
I think that you'll create a custom dialog, this link shows you how to do this http://developer.android.com/guide/topics/ui/dialogs.html

Android create two dialog in one activity

I'm really interested if I can create two dialogs in Android in same time in one activity. Here is what I want to achieve : I want to have a circle progress bar with a cancel button and at the bottom of my activity to have a horizontal progress dialog which indicates some calculations. Is there any option to create something like this or similar to this?
Thanks in Advance!
There is no reason why the synchronizing bar, progress bar, and cancel button could not be part of the same dialog that has a transparent background.
You can call
ProgressDialog#getWindow#setGravity(...) to change the gravity.
So:
ProgressDialog dialog = ProgressDialog.show(AContext, "Test", "On the bottom");
dialog.getWindow().setGravity(Gravity.BOTTOM);
You cannot show multiple dialogs at the same time, however you can create an activity with a transparent background which looks like two different dialogs.

How To Get A Pop Up Layout?

How can I have a pop-up window, with a new layout, but with the old layout in the background?
Also I'd like to have a button on the first layout call the second layout based on an if-statement, using something like this
"if Button has a background, button open new layout, if not null"
You could use a Dialog to create the pop-up. For example, in your activity onCreate() method set up a new dialog and specify the layout using XML like normal.
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.--);
then simply call dialog.show() when you want to show the pop-up.

Transparent Alert Dialog box

I have few doubts regarding transparent AlertDialog box in android.I have created the alert dialog box using AlertDialog.builder in the camera surface view but i want Transparent alert dialog box is it possible. please help me
Regards
Raj
Use this
The code is as follows
Dialog mDialog = new Dialog(mContext, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
Answer taken from a similar answer here
Yes, this is possible. I believe you can do it by creating a custom alert dialog:
http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
you can then set the background of your custom dialog to transparent like so:
this.getWindow().setBackgroundDrawableResource(R.drawable.transparent);
(where "R.drawable.transparent" is a reference to the color "#00000000")

Categories

Resources