How to disable background screen - android

I have a LinearLayout A which is set inside onCreate() method by setContentView(), However i am creating a PopUp at runtime in same activity which is also a LinearLayout B, PopUp placed just bottom of the screen/activity, I want to to disable the background screen so that no touch/tap/click work.
How can i do that.
Thanks

This is how I could do it... I would recommend that you make the root of your layout a RelativeLayout, then put your LinearLayout A inside that. Your LinearLayout B should be the full size of your screen and have two views inside it (a top and bottom). The bottom view is your PopUp that you are already using. The top will just be a basic View that has a background color set to black with a .25 (or .1) alpha on it so that it's almost entirely see through.
When you want to display your popup (and disable interaction with the controls outside of the popup), add LinearLayout B to your relative layout attached to the top left (i.e. B should completely cover A). The user will be able to interact with your popup controls at the bottom and still be able to see LinearLayout A through the mostly transparent top portion of layout B, but since it is slightly grayed out the user will know they aren't allowed to interact with it... and will be prevented from interacting with it because the overlay view will block interaction.

Related

Making simple UI change animations. Pop-ups sliding from the edge of the screen

The questions are quite FAQ-type, but I can't find any suitable tutorial and don't even know what exactly to search for
1) I've got a list filled with linearLayouts and need to set an animation for elements added to those layouts as shown on image. The animation is the element slides from under the existing layout elements. If an element is removed, the animation is the same reversed
2) There is a screen filled with elements. Tapping, for example, a certain button, you call a pop-up, which comes from the edge of the screen and is above the rest of the elements.
If you tap anywhere, except the pop-up,
a) it will slide back
b) you will interact with the objects which the pop-up does not cover
What makes such effects possible? How to implement them and what to read about?
For 1) Setting animateLayoutChanges=true for LinearLayout should do the job
For 2) You can open a Dialog on button click and customise the animations for the dialog by calling dialog.getWindow().setWindowAnimations('id of animation xml')

How do I make a section of an activity always-on-top?

Had a question about making part of a View Always-On-Top. Please see the Groupon picture below. The black window at the bottom where it says "From $29" & "Buy!" is always on top of the activity page. Meaning the rest of the page is scrollable above that black window at the bottom. Please note I only want this activity to have an Always-On-Top
How do I make a portion of the activity Always On Top? And what kind of layout did you think they used for Groupon? I was just going to make a RelativeLayout and layout_alignParentBottom="true".
You could probably get away with having a vertical linear layout with two children. The first one a scrollable area and the bottom a view with whatever it is you want to be 'on top'. Since there's no transparency there's no visual difference between having the black view as always-on-top and having one view on top of the other (in the y-axis, not z-axis). Plus, if you do it this way you can reach and see the bottom of the scrollable view's content.
To the best of my knowledge, the best way to do this is by implementing a BaseActivity with this View, and have all your activities extend this activity instead of the standard Activity.

Android - How to bring to front a webview

I have two Webviews but at certain point i would like to bring the one on the back to front. I want both visible.
Is it possible to change the layout order?
There is no concept of Z-axis position in Android view stack so you can't bring views to front or send to back. You need to set the view's visibility flag to hide, visible or invisible (.setVisibility(GONE , VISIBLE, or INVISIBLE) respectively). If you want them both visible at times then you need to have at least the top view (the one added to the parent view last) be with transparent background so that if their Visibilities are set to VISIBLE then the behind view will show through the top view.
Kevin

How to lay a layout over another android

I've followed this guide to make the sliding menu like the facebook app has.
When the Button is pressed, a new Layout shows from the left of the screen. But it pushes the orginal Layout with elements to the right of the screen. How can I make the Layout lay over the orginal Layout?
See the link for code samples. Thanks!
Let me rephrase my question
When I press the button, the text of the button, and the button itself will be pushed to one side, and aligned vertically. How can I just push the button "out of the screen"
To overlap layout/views above each other, you need to use FrameLayout. It sets the visibility of view (e.g. z-index in CSS) in the order as they are defined.
Sounds like you are adding the new layout to the parent layout which is why its pushing the original layout out of the way. You need to add the new layout to the original layout and it will lay in the original layout.

Sliding in a layout for user input

I have a ListView and each item contains a TextView displaying a number. I'd like to give my users the ability to change this number while staying on the ListView (as opposed to drilling down into a detailed view by clicking on the list item).
What I'm looking to do is to slide in a layout from the bottom of the screen that covers about half of the screen. I'd like this layout to be OVER the Activity behind it (as opposed to being part of that Activity's layout and simply showing it). I'd also like it to be model (or seem modal). Meaning the Activity behind it can not be focused and manipulated. In this layout I will essentially create a calculator.
What I need help with right now is:
1) How to display a layout over the current Activity
2) How make the background (the Activity) modal
Could someone point me to some tutorials/resources and/or give me a few tips?
use an Animation. here is a small tutorial on them: http://developerlife.com/tutorials/?p=343
initially, the view you want to be modal must be placed where you want it to show up(and visibility set to gone).
use a translate animation to visually move the view from below the screen to halfway up the screen. once the animation starts, set visibility to visible
try disabling all views that the user should not be able to interact with after you have started the animation holding the calculator view

Categories

Resources