Activity Dialog with black screen around - android

I have a problem with closing my Activity. I'm want to start activity by alarm. I've done that alarm start my activity, but I want to make it a dialog, so I set theme of that activity to android:Theme.Holo.Dialog.NoActionBar but I looks like this:
http://i.stack.imgur.com/rlfx1.png
I've also tried adding:
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Translucent</item>
<item name="android:windowBackground">#android:color/transparent</item>
But I makes transparent not elements that I want to, it looks like that
http://i.stack.imgur.com/BfvDL.png
Is there way to fix this, or do you have any diferent ideas to make this heppen.
Thanks

Related

Not able to set transparent background for Popup Window Activity

I am following this particular example to create a popup window activity but when I click on a button to open this activity, the background is not semi-transparent as mentioned in the example. I am new to android kotlin development so I am not able to figure this out on my own. Let me know what I am doing wrong.
EDIT: This link tells a different method but working fine.
You can customize the translucent theme of your activity, in your "AndroidManifest.xml" file.
<activity
android:name=".ui.PopUpWindow"
android:theme="#style/AppTheme_translucent" />
and in your "styles.xml" file.
<style name="AppTheme_translucent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowBackground">#color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
</style>
I travel the code and did not see setContentView() method for PopupWindow activity. Please set content view for the activity by calling the method inside PopupWindow's onCreate()

Changing default Android fade/scrim color when calling a Dialog

I've been working on an app and I've reaching the point where it requires me to display a menu window in the middle of the screen.
I've been using an AlertDialog object filled with a custom View but now it was required of me to "surround" the window with a semi-transparent white glow as opposed to the default grayish one. I did a similar with the fade-in color of some navigation drawers I have on my app but in that case I had a specific method to quickly help me solve that problem. So far I haven't found anything that helps me solve this one.
I tried creating a default style with a new "windowBackground" value but I encountered 3 problems from the get-go:
I'm no longer able to shut the AlertDialog down by clicking outside the layout (I'm guessing because by changing the color that way everything is now the layout)
The menu window is now surrounded by a black outline that wasn't there before
By using the filtering search inside the layout, which manipulates the members of a list, the window collapses on itself
Is there any way to accomplish what I want more or less directly?
I'm not really sure about it, but you can use this in your styles.xml
<style name="MyDialogTheme" parent="android:Theme.AppCompat.Light.Dialog">
<item name="android:windowFrame">#null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#color/your_light_color</item>
<item name="android:backgroundDimEnabled">false</item>
And if you want to dismiss the dialog when clicking outside, use this:
dialog.setCanceledOnTouchOutside(true);
or
<item name="windowCloseOnTouchOutside">true</item>
in your styles.xml

Circular reveal on activity with fragment

I have problem with circular reveal on my fragment. Whenever I call my reveal, it starts a new Activity and then inside onCreateView in fragment, it calls my reveal.
It works, but there is one glitch – as I start a new Activity, everything turns white. The Activity's background is white and covers data under it. Is it possible to show this data and not overlay it with this white background? Or should I make some kind of mask, animate it, and at the end start Activity?
I had the same issue and resolved it by using a transparent activity. To make your Activity transparent, use this code.
Theme Definition in styles.xml
<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:windowBackground">#android:color/transparent</item>
</style>
Activity Definition in AndroidManifest.xml
<activity
android:name=".ui.CircularRevealActivity"
android:theme="#style/Theme.Transparent"
android:launchMode="singleTask"
/>
For a full answer on how to use a circular reveal animation on an activity, you can check this link.

Shared element transition with Dialog Activity

I put together a very simple app that uses shared element transitions when starting an activity with Dialog theme (source code on github).
I got the following result:
As you can see there are 2 problems with the transition/animation:
The animation is only visible in the area of the dialog activity so it clips and looks ugly.
There is no transition/animation when I tap outside the activity to
go back.
How can I fix these problems? Any help would be appreciated.
EDIT: After Quanturium's answer I did the following things to get it working:
Use the following theme instead of a Dialog theme:
<style name="AppTheme.Transparent" parent="AppTheme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
Use a CardView as the background for Dialog look and for rounded corners and shadows.
Call finishAfterTransition(); when user taps outside the CardView.
Now it looks like this (code), the CardView needs refining to better match the Dialog, but it's working at least.:
An activity transition works like this. When you start your second activity, it is displayed on top of your first one with a transparent background. The shared elements are positioned the same way they are on the first activity and then animated to the correct position specified on the second activity.
In your case you are using android:theme="#style/Theme.AppCompat.Dialog" which mean the size of the second activity's drawing area is smaller than the one from the first activity. This explains the clipping and the no transition when clicking outside.
What you want to do is get rid of that theme, and implement your own layout with a dark background / shadow in order to be able to execute your smooth transition.

Open activity using a expand animation

I need to open a activity at the right part of the screen but still view the old activity at the left part of the screen.
It can be something like a dialog but i need to specify the position of the new activity and also remove the overlay look and feel.
how can i make this?
I have already achieve my first step. putting the activity at a specific position and see the main at the left of screen.
I have used the following style:
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
in my layout file i have setted my linear layout like this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="200dp"
android:layout_height="200dp"
android:orientation="vertical"
android:background="#drawable/background_login"
android:layout_gravity="top|right">
this way the activity goes to where i want. now i just need to open the activity with an expand animation and close it with an collapse animation.
Can someone tell me how?
Seems like you're looking for Fragments. Multiple fragments can be shown next to each other, so one fragment can be your left part of the screen and another one be opened on the right side.
Please refer to the Android Dev Guide for more information.

Categories

Resources