I have implemented a custom Dialog in android. The custom view contains curved edges but not the Dialog itself. I want this Dialog to get the shape of curved edges. How it can be done?
As you can see, the curved edges are not actually curve.
Any help or idea would be highly appreciated.
SOLUTION
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Thanks everyone.
Happy coding.
I guess there are two possible reasons that make your custom view like this:
You forget set the dialog's background transparent first;
The custom background image's corner part is not set transparent.(you can set it transparent and save it with png format.)
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.
You need to create a custom dialog in Android.
Create a custom dialog layout (XML file).
Attach the layout to Dialog.
Please check below Demo Links
Android Custom Dialog Tutorial
How to create custom Dialog Box in android ?
Related
I'm looking for a way to hide the underlying activity of an AlertDialog.
I tried to set a solid overlay color but it looks like there are no default methods for doing this. Is there a way to do this without creating a new activity with a solid background color that then fires the dialog?
I couldn't find anything other than doing it by firing a whole new activity on StackOverFlow, google, the android documentation and the AlertDialog API page but this seems like overkill.
Ideally I'm looking for something like alert.setOverlayColor(int color)
Create a custom layout for the Dialog with height and width as "match_parent". Use the area required by dialog and put a solid background in the top level.
I would like to create some "dialogs" like those shown in Android 4.4 for example when you are first shown immersive mode. The little arrow is important for me because I would like to have the dialogin different places on the screen.
This is what I'm talking about:
Do I need to create a custom AlertDialog? How do I move it around, can I use the coordinates of a View? I don't really know where to start. Are there any examples on creating this type of thing? I am not interested in using the ShowcaseView library as in my opinion has the "old" holo look.
You can get the coordinate of views using getLocationOnScreen(), make sure to call this after the views have been inflated (so, not in onCreate() of your activity) or else you will be returned default int values (i.e. 0).
You should probably create your own DialogFragment. Incorporate your own custom layout which contains the little bubble and the button. A Quick and dirty sample for the onCreateDialog() would have the following
Dialog dialog = new Dialog(getActivity());
// Get rid of the annoying alert dialog title bar
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
// You must set the content view after requesting window features, not before.
dialog.setContentView(someView);
// Make the dialog full screen
dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
//Dim the background
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.argb(80, 0, 0, 0));
To incorporate the little arrow, you can try having variations of 9-patch images as the background of the little bubble. Another alternative would be to have an arrowhead and a bubble put into the same container, and setting the margin/padding between them to 0. Since you have the coordinates you can adjust the horizontal margins of the arrowhead accordingly. This is actually a pretty cool idea, I think I'll try my own interpretation of it this weekend.
I have actually been working on my own interpretation of the showcase library, Here is what i achieved. Much of the dynamic position changing should be the same I would think
Can you please tell me how to make this type of pop up? I do not need to design own component in drawable. I don't have much knowledge in Android.
1) First there is Title with blue background .
2) Second there is scrolling list view (without image) and buy button (without image).
Is it possible?
I Googled it to find out if we can make own button like that with some style?
Here is my image
You have to use a Dialog/Pop up in combination with a ListView you have to google that up because its a complex theme.
good look
Start from http://developer.android.com/guide/topics/ui/dialogs.html. You have to implement your own custom dialog layout, likely using a ListView (http://developer.android.com/guide/topics/ui/layout/listview.html).
I have an android application which uses a custom Alert Dialog for showing an image and its description.
I want to make this dialog
Pop up from center like in iPhone.
Push down to center when cancelling.
I know that it is possible by applying animations/styles.How can i make style for this purpose?How to use this?
Thanks in advance
Dialog, was defined in doc, 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. With it's subclasses (AlertDialog, ProgressDialog, AppCompatDialog,...), they become a alert system in Android. For making more exciting when they appear/exit, we can set animation for them easily. In this tip, I provide a way to do this trick through styles resource.
http://www.devexchanges.info/2015/10/showing-dialog-with-animation-in-android.html
All,
1.) I have a Dialog showing on my application. Right now it is showing in the center of the device. But i want to see that dialog in Top of layout. How to move it?
2.) How to add an image in a Dialog box?
EDIT: I added an image in background of Button. I want to move this button into right corner of Pop up Dialog. How to do that? And also i want to know how to move the entire Pop up Dialog itself into Top of the Layout screen?
As i'm new to this development, please some one suggest me how do i achieve this?
EDIT:
CAN SOME ONE TELL ME HOW TO MAKE THREE CONTROLS IN A SINGLE LINE USING LAYOUT? I WANT TO SHOW AN IMABE, A BUTTON AND TEXT LABEL IN A SINGLE LINE. I TRIED THAT ON LAYOUT IN ECLIPSE. BUT IT ACCEPTS ONLY ONE CONTROL FOR ONE LINE, IF ADD NEXT CONTROL IT GOES TO NEXT LINE(ROW). I WANT TO MAKE THREE CONTROLS TO BE IN SINGLE LINE. HOW DO I ACHIEVE THIS?
After creating the dialog you can call dialog.getWindow().setGravity(Gravity.TOP)
If u want to change height and width
dialog.getWindow().getAttributes().... This will return WindowManager.LayoutParams
you can set ur values and use setAttributes() function
I am not aware of an API to change the position of a dialog. You may be better served creating an activity and using android:theme="#android:style/Theme.Dialog" to make it look like a dialog.
If you go that route, you will then be able to use all of the standard techniques for placing widgets (e.g., images) wherever you like.