How to customize dialog background? - android

I want to implement a regular functional dialog, as well as text and a drawable on top of the gray overlay.
I did some research, but I was wondering if someone knows a better way of doing it. Here are a few thoughts:
1) The dirtiest way is to ditch the dialog and create a view with a fake dialog. That would be very easy, but is the least preferable because dialogs look different on different Android versions. Also it would be nice to reuse some of the Dialog stuff that has already been implemented.
2) A slightly better way would be to reuse the parts of Dialog xml file, but it's still "reinventing the wheel" a bit too much.
3) It would be great if I could just inflate a layout for the background and do dialog.setBackground but I couldn't find anything like that.
4) I tried inflating a layout and setting it using .setView() on the AlertDialog.Builder but it seems like it alters the dialog itself, not the background.

Related

How can I create this custom pop-up message in Android activity?

I am tasked with creating this kind of pop-up message for an app. I attached an image bellow with the design,
Note that the pop-up is placed right bellow a certain ImageButton to indicate something about it. The pop-up must also contain an ImageView, a TextView and two Buttons.
I know that the Alert Dialog native for Android opens a Dialog Popup at the center of the screen that has a rectangular shape and also makes the background behind it darker. But I want to create something that matches this design exactly and right now I have no idea how.
Can anyone show me how to do this, if necessary, even a library would help. All that matters is that the solution has to work on any Android OS equal or higher than v6.0 (Marshmallow).
Thank You!
Below popup library will help
https://android-arsenal.com/details/1/2927
you can inflate your custom View into this library

Adapting AlertDialog to a specific design

I need to edit default AlertDialog theme so that it will look like part of the design of my app. I don't want to create a whole new theme for it. I will just play with its own properties and make small changes. But the problem is I can't manage to reach the source code and I don't know what kind of attributes it has.
What I need to do is basically to give background a little transparency and roundness.
Does anyone know where can I get the AlertDialog style code? And which attributes do I need to edit for transparency and roundness of background?
Thanks.
Here's the style code for AlertDialog: https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/styles.xml
I don't know how to change it the way you want though.

How to style the children Views from the parent View?

I am currently trying to get the look of my app right. But I am having problems figuring out how to even set up a way to change themes. For one thing, is there even a way to change styles through code? I checked the method list and I saw nothing. This leads me to my actual question; is there a way that, like CSS, in which you style the parent, and then have it trickle down but also changed depending on the View? I looked at the Android docs, and they did not show any examples of this. Hopefully someone can give me an idea as to how to accomplish this, or if its not possible, to let me know that as well. Thanks in advance.
You should be able to do this using styles and themes. I've implemented this using Jake whartons Sherlock action bar. (I'm not certain if it's necessary) It involves using the comparability library which gives you the ability to use fragments and loaders as well. Look at his democode at http://actionbarsherlock.com/download.html. Look for where themes are mentioned and you will find the information you need. In the demo app you can change the theme in the top right corner and see how it affects the activities look and feel. It also shows many of the features available and the code to write them. I have found this an invaluable resource and it should show you how to theme your app.

Android: Simple customization of AlertDialogs

I have read lots of articles, here and elsewhere about customizing AlertDialogs, and those created by AlertDialog.Builder.
The approach that I'm using at the moment is injecting my AlertDialog.Builder with a ContextThemeWrapper. This ContextThemeWrapper is configured to read from a custom style that inherits from Theme.Dialog.
My customization requirements are quite straightforward:
Change the title bar background colour from the default navy/black version
Change the font type and size of both title and buttons
I've had a look in the default themes.xml and styles.xml but I don't see where to configure number 1 in particular...can someone let me know how this is done?
Also, some of the solutions I've seen involve inflating a layout and then setting this using AlertDialog.Builder.setView()...if I was to customize using this way then how do I design the views for positive and negative buttons?
Thanks
Sorry, alert dialogs are not really intended to be themed like that. They are basically the most concrete thing you can do -- a canned appearance for standard common situations.
If you want to have a dialog with a customized appearance, you should just start with the Dialog class.

Is it possible to create an Android AlertDialog without a border?

I'd like to an AlertDialog that has no border. Currently all AlertDialogs on my 2 phones have borders, with the borders looking different on each phone. I'm guessing this is due to manufacturer customization.
I know I can use a standard Dialog for more control, but hope to avoid that if possible.
Take a look here: Android Borderless Dialog
A custom xml layout for the dialog should do the trick :)

Categories

Resources