Disable background activity in android - android

I currently have an activity that displays a gridView. When a specific button is pressed I create a new fragment that has a transparent content view so that it overlays the activity gridView, so basically you see the content of the new fragment while still vaguely seeing the gridView in die background. The problem I have is that the background view (the gridView) is still active and the user is able to press buttons "through" the fragment view and onto the gridView, if this makes sense. How can I disable the background view/activity (gridView) so the user cannot activate any of the content hosted by it? I was thinking I could do something along the following lines, but it seems very inefficient and hackish:
ViewGroup vg = (ViewGroup) v;
for (int i = 0;i<vg.getChildCount();i++) {
enableViews(vg.getChildAt(i), enabled);
}
Is there any other solution or approach I could take?
I set my transparency for the entire fragments view via style like this:
<style name="Transparent" parent="#android:style/Theme.NoTitleBar">
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:background">#e6000000</item>
</style>

Not sure why this question got down voted as I feel it was a legitimate question, perhaps my phrasing was bad or something. Anyways, I've found a solution incase anyone else ever runs into a similar situation. All you need to do is to set the overlay screens root layout clickable property to true: (in this particular case the fragments main layout)
android:clickable="true"

Related

Android Dialogue Fragment not moving up when keyboard is visible

I have implemented a custom dialogue fragment which contains a custom view pager and an edittext.View pager contains a grid. To move the view upwards when keyboard is visible I have placed the view inside a scrollview. When app is running view pager is not displaying. How can I make this custom fragment scrollable when keypad is visible. Please help me. Thanks in advance.
Add android:windowSoftInputMode="adjustPan" to the corresponding activity tag in your application manifest file.
In my case I tried everything, however the problem was not in the implementation of the dialog, or how the keyboard was invoked. I was using a theme to make the status bar translucent and that caused the wrong behavior, by changing to another theme the dialog goes up without problems when invoking the keyboard. I hope my answer is helpful
I was using this style
<style name="TranslucentTheme" parent="MyTheme">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:fitsSystemWindows">true</item>
</style>

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

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.

Google Glass CardScrollView does not render while swiping

I'm attempting to create a GDK app that has a similar user interface as the sample Timer app in that it launches sub-activities in which to render CardScrollView instances that cycle through valid selections.
My problem is that once I am at the point where I cycle through the numbers, the CardScrollView stops rendering while the scrolling is in motion. I can see the previous activity revealed and rendering until the activity containing the currently active cards stop scrolling.
Is there something obvious I'm missing here?
In my case, the answer was that I'd foolishly applied the "MenuStyle" style that the Timer activity uses to all my sub-activities in the AndroidManifest. This style specifies the following:
<style name="MenuTheme" parent="#android:style/Theme.DeviceDefault">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">#null</item>
</style>
So indeed, given the null animation style and the transparent background, nothing would be displayed while the CardScrollView is in motion.

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