Android PopupWindow: White background but keep shadow? - android

How do I style my PopupWindow in Android with a white background but still keep the shadow? I am trying to create something like [this][1]:
By default, my PopupWindow has a dark background. So I set the popup window's contents to have a white background which gives me this:
Which has a shadow but still has the black "border" which really is just the uncovered parts of the popup window background.
So I try and set the popup window background to white with:
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE))
which causes this:
which gives the correct background colour but also removes the shadow.
So is there any easy way to keep the shadow but set the background as white. Is there something else I should use instead of PopupWindow to create what I want? Or do I have to use a 9 patch or something?

I just ended up using a 9 patch created with http://inloop.github.io/shadow4android/

after set background,just add elevation.
popupWindow.setElevation(10);
this will work after API21.

If nothing works, you can use below code. This will place a shadow around Popupwindow with white background. I've tested it in my app.
popupWindow.setBackgroundDrawable(context.getDrawable(android.R.drawable.picture_frame));

Related

How to change the default color of BottomSheet to transparent?

I have tried numerous ways to change the default white background to transparent
List item
Changing my root layout color to transparent
Changing the window color of bottomsheet to transparent programmatically by implementing following code.
bottomsheetdialog.getwindow()
.setBackgroungDrawable(new ColorDrawable(Color.TRANSPARENT));
None of the above worked.
Any suggestions to make it work?

Changing the background of an androidplots to white

I have being playing around with the ListView of XYPlots. I was able to change background either by using style="#style/APDefacto.Light" or style="#style/APDefacto.Dark". These two work well but, I want my graph to have complete white background instead of a light or dark background.
Screenshot with the light background.
If you look carefully at the graph, you will see that the background has a grey color but the graph itself is white. I want the whole background to be completely white.
I have try the solution of the link Change the background color of XYplot in android to white?. But that only have the effect of removing the square on the graph but no change is seen on the background.
Below is the resulting screenshot.
Any clues,
Thanks.
Just add these attrs to your XYPlot's xml:
ap:backgroundColor="#FFF"
ap:graphBackgroundColor="#FFF"

Transparent Tint on Buttons

In my Android app, I'm trying to get buttons to be tinted a certain color (either blue, red or gold). The default button tint is grey. Does anyone know how to change the color of the button so that the transparency remains with it?
I tried using:android:background
but that ditches the transparency completely and makes the button one solid color.
I also tried using:android:#color/transparent
but that ditches the color completely in favor of a fully transparent button. I've looked online for a while and found mostly stuff relating to image buttons. The kind that I'm trying to tint is just the standard Button buttons. I'm also guessing that this can be done mostly just through XML. Is that correct?
You could try and create your own button drawable like so...
Take the button drawable from the Android SDK ([ANDROID_SDK_HOME]/platforms/data/res) and import the drawables into your project. Then create a layer list with the button drawable on the bottom and a semi-transparent color on top.

How to Change the Color Behind Android Dialog

I would like to change the color of the dimmed background that surrounds an Android dialog (not the Window background drawable) programmatically. I am using a dialog themed activity. I do not want to dim it, nor blur it.
If you imagine a dialog with three buttons, I would like to have it do something like this:
Click A: background to translucent red
Click B: background to translucent yellow
Click C: background to translucent green
I'm not sure you can change the color of the background. The dimming is controlled by the dimAmount field of the layout for the dialog window (as well as the FLAG_DIM_BEHIND flag). dimAmount is just a float between 0.0 and 1.0 that controls the amount of dimming (transparent to totally opaque). I think it's just an alpha blend of the existing background; there's no control of coloring as far as I've been able to find.
If you're using Activity with Theme.Dialog then you should look into your xml file for layout and then change background color of outermost container.

Transparent LinearLayout with buttons (Android)

I'm trying to make a menu with buttons, and my problem is that i want this menu to be over a camera view (I'm working on Augmented Reality).
But if I make my menu appear it makes the background black instead of having the video of my camera.
Any ideas how to make this background transparent? I tried with :
menu.setBackgroundColor(Color.TRANSPARENT);
but there is no modification :/...
OK. Then you can change the background of the menu as any transperent image. Or you can change the theme in Manifest file to black so that can shows the white background in your Application
Try: menu.setBackgroundColor(Color.alpha(0));

Categories

Resources