I want to make Semi Transaparent Activity Like pop window i.e. As my appActivity starts one pop up window on top that should come and user should click proceed button to go on that activity. I have seen dialog as well as Alert Box but they are widget. I want to use the screen as activity so that I can put xml layout .
I have come across PopWindow but I do not know how to use it .I have made one class PopupWindow When I try to achieve findviewbyid I am unable to achieve it becoz PopupWindow class is not extending anything ....
So what should i use if popWindow class then how to use it ? thanks
create an layout as you like to have as a dialogue and create an activity using that layout.
in the manifest declare that activity and add android:theme="#android:style/Theme.Dialog in that activity stub.
Related
https://developer.android.com/reference/android/widget/PopupWindow
I am trying to keep my popupWindow when changing activities, and not recreating it each time I change activity.
Is this possible?
In the docs it says that -
This class represents a popup window that can be used to display an arbitrary view. The popup window is a floating container that appears on top of the current activity.
It states current activity, but is there a property I can set that will only change the activity behind the popup ?
Thank you !
I am finding the solution from last few days, a solution will appreciate.
The scenario is:
There are two activities in my application 1. mainActivity 2.newActivity. On button click on mainActivity newActivity will be open as a pop-up window(not a dialog box). I want to hide/blur mainActivity when pop-up window(newActivity) is active and display mainActivity when pop-up(newActivity) activity close. how can I achieve this?
You can set background color code "#CC000000" of "newActivity" in xml layout.
Just use android:background="#CC000000" for your main Layout.
I would suggest putting an opaque Drawable or background (either black for darkening or white for fading) behind your popup.
This is not blurring the main activity but it highlits the foreground popup.
Just use a color like:
<color name="Translucent">#80000000</color>
I have requirement of creating two activities and their layout programmatically. And I want to create something like this,
Create a first activity and with a fixed background and second activity which will have a transparent area at all side so there the view of first activity will be shown.
Right now I am creating one activity and it shows OK.
and
setTheme( android.R.style.Theme_Translucent );
when i open second activity the view shows with margin but with the plain background and not the transparent view of first activity.
I have set the back ground of second activity like this, rLayout.setBackgroundColor(Color.parseColor("#80000000"));
It is showing the grey color at background.
I know a one work around by creating dialog, But it would be better to use activity as per our requirement.
You can create a transparent theme in styles and then use that style for your transparent Activity.
Refer to this answer:
How do I create a transparent Activity on Android?
I have a popup which I implement with an activity, e.i the activity doesn't fill the whole screen, and looks like a popup.
How can I disable the caller activity? (The background activity).
I want the same functionality as if I used a classic popup:
popup.setOutsideTouchable(false);
Thanks in advance!
you can create an activity with
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen".
There add your view over the transparent activity like a popup.
I am using a dialog themed activity in android to show a popup from a application context. The dialog has a transparent theme, but the issue is that I want the underlying activity to have focus and not the popup though the popup must be visble. How do I achieve this in android?
I think you would have to use a Fragment and just make it look like a popup dialog.
You can not switch focus between activities. There's only one activity "on focus" at the time, and is the one that is being displayed at that point. The transparent background doesn't mean you can access the activity below.
If i don't get it wrong, you want to be able to interact with the activity's controls while having a "Dialog" on the screen. Any sort of Dialog class from Android will not help, since they take the focus away. Not really sure about PopupWindow, but i'm guessing will be the same thing as the documentation says "that appears on top of the current activity."
You are going to have to create a custom dialog using a RelativeLayout/FrameLayout within your activity.