Placing a translucent-like image in Android - android

How can I place a gray image on top of my whole activity? This gray image must be translucent (meaning the user must still see what is beneath that gray image).
I wanted to created something like the pause menu in most games wherein the background can still be seen and when clicked/tapped, it becomes invisible and continues on with the game. :)

You could open a new activity that has a semi-transparent background. Or open a dialog, and have Android take care of it by itself.
If you want to use the same activity, create an ImageView over the entire activity, load it with a semi-transparent image, and set its visibility to 'gone' until you want it to appear.

You could also use FLAG_DIM_BEHIND instead of an translucent image
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_DIM_BEHIND

Related

Blurring A Dialog in Android

I looked through forums and SO and find many examples on how to display a dialog with a blurred and dim background which I put in place in my app. The issue I have now is when I want to display a second dialog on top of the previous one but still keeping both on the screen. The effect I would like is to dim and blur the background a second time when the second pop-up shows up. But what it does at the moment is blurring the activity again and not blurring the dialog that is still showing in the background.
So my question would be, is it possible to blur a dialog, when opening another dialog? If yes how could I do this? (Make sure you read the question well... I know how to blur the activity, the question is how to blur the dialog already shown on screen when I open a new dialog on top of it....)
Thanks very much
you can create fullscreen dialog with custom layout which consist from
real dialog content and blurred transparent part outside which would blur and overlay all background views.

Android: Create Activity not Full Screen with Transparent Background

I'd like to create an Activity smaller than full screen and having around it a transparent background.
Using re-size function I was able to create layer smaller than full screen, but I don't know how to create transparent background.
In my mind, if you tap on the background nothing should happen, but, in my case (simply re-sizing) activity, when you tap somewhere outside of activity, it loses the focus and disappears.
Any ideas?
Many thanks!
What about making your own style and putting:
<item name="android:windowCloseOnTouchOutside">false</item>

Android ImageButton - How to hide the image while showing the background?

I've read the API and Googled but perhaps I've missed something: All the visibility options on an ImageButton seem to talk about this view as a whole. So, what should I do if I want to hide the image but keep the background(except for explicitly setting the image to something transparent that is)? I'm doing a Pairs Game and when one clicks on the element it should show the image and if the next click doesn't match the image should be hidden, but the grey background of the button should remain.
Thanks!
So, what should I do if I want to hide the image
Try setting it to #null or create transparent PNG in your drawables and set it.
in XML, remove android:src="something" and in the code remove imgbtn.setImageBitmap(null);
Instead of using ImageButton you can use ImageView with a FrameLayout on top of it. Set the background of FrameLayout as gray color and then show/hide this FrameLayout/Image as per your requirement. Take relative layout for each and make it clickable. On the click event of this layout, do the changes as required.

how to click Background and something should happend?

I want to click the Background of a layout (not clicking anywhere, for example in the top right) and then reproduce a sound, can i put an empty View and put an On Click to that? I think is not possible.
If is possible, there is a better way?
I want to put some invisible "buttons" at the Background because I will put an image Background with shapes, that's why It couldn't be anywhere.
Thanks and sorry for my english.
You can put a button on the right corner and apply an empty or simply transparent image as icon button.
In this way, you can choose a different behavior for each screen position.

How can I tint/ dim an Activity

I have a button in my actionbar, when I click that I want to dim the current Activity. Fading the alpha wont work because the background is white and I need it to darken.
Cheers
Probably the simplest way would be to create a View scaled to cover the entire activity end set its background color to something half-transparent. You can also check how the stock Alarm app does it.
Cover the entire layout with Dim Gray transparent image (i.e.., overlay the image with the entire screen). I hope this idea will work for you

Categories

Resources