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>
Related
I have an app where I used the dark theme. I have also added a splash screen where I have added an animation. The background of the SplashActivity is white. When I first start the app, I get a dark screen and then the splash screen is displayed. How to get rid of that dark screen and see directly the splash screen? Thanks
Its related to Cold Start. It happens when your app starts for the first time as explained in the android documentation. However to deal with it I prefer the solution of having background drawable and set it to app theme if your Splash screen is static but in your case as you are using animations you need to use mixture of both techniques i.e. setting the splash screen theme as drawable which is loaded during cold start and later on when it finishes you render your animated stuff.
I have a problem of white screen when I relaunch background app.
I click home button and then I click on app logo, my application resume and sometimes I have a white screen.
Do you know what's happening please?
This is the time that your application takes starting, before first activity is displayed.
If you extended the application class, you can look at the onCreate method, if there is much code here.
You can minimize the effects, setting the default window background to a color or drawable in a theme:
<item name="android:windowBackground">#color/mycolor</item>
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
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
I'm changing the background drawable for my buttons when they're clicked (as they trigger functions such as play/record). While playing/recording, the button glows (a different 9-patch is set as the background) and turns into a stop button. My problem is that currently I'm using:
b.setBackgroundResource(R.drawable.btn_default_normal);
to set the background back again afterwards. This works, but the normal behaviour when I use setEnabled(false) is lost. After a button has been used, and reset to normal, it retains the normal background (rather than the dimmed one) when disabled. The text still changes colour though. Is there a way of 'resetting' the background of the button to default, so that it retains its normal behaviour?
Ok, I got the answer from this blog post in the end. What you have to do is create an xml document with all the different button states, and assign that rather than just an image to the background.