Covering most of a view with an overlay Android - android

When covering a view with an overlay I am aware that I need to use a FrameLayout, and the child views stack on top of each other. Setting a view to having a background with opacity will create the overlay effect. However, in my situation, I am required to create a hole in my overlay to display the contents of a tab item / other views beneath it. This is where I am stuck.
I am not sure how to perform the intersection on the view so that it is transparent in a specific area of the view (which I need to determine based upon the position of a specific View element (Tab, ImageView, etc).
The image above shows the result I want to achieve. With the entire view having an overlay on it, besides one of the Tabs and the Info box (which needs to move based on the view displayed through the overlay).
I believe I need an intersection of the views to achieve the result I need...this is something I am not sure about. Can someone point me in the right direction of a solution please, I do not expect to be just given a solution, its all about learning!

Related

Cleanly rounded list items Android Studio XML

I am attempting to create a nicely rounded list similar to the one shown below:
The items displayed will scroll when a user wishes to pass 6 items. I was wondering how I could make the recycler view, within this rounded cabinet, rounded at the top and bottom; such that an effect is created to match the draft displayed above.
If anyone could tell me how to round the corners of a recylcer view, cleanly without artifact, like this (within XML) it would be greatly appreciated. Just for information, I have tried something; that being the process of putting the recycler view inside a cardview and allowing the cardview to clip the recycler. However, this results in some weird pixel outlines (artifacts) at the bottom edge. I have shown it here:
You can see a set of stray pixels which, while not neccesarily too obvious, make it slightly jarring to view for both a user and myself

Create custom Layout with non-rectangle views and set clickListener for overlapping views in android

Is there any way to make following Layout in Android..? If yes please suggest how to make and how to set clickListener's of overlapping areas of Views...? i.e View 2's area overlaps 1's area and View 3's area overlaps 2'sand 4's area and so on others views overlaps..? If there is any android library to make non-rectangle buttons/Views also suggest.. Thanks.
Here is one way that this may work:
Use a rectangular ImageView for each shape. Make sure each shape is clickable.
Shape images will have a transparent portion where they fit together.
Use FrameLayout or some similar layout that will allow overlapping of Views. You will have to work with how each View overlaps.
Make the transparent portions un-clickable. See this Stack Overflow question and its accepted answer regarding one way to do this. (N.B. I have not tested this.) You should be able to work it so that clicks propagate downward to an underlying ImageView when a transparent region is clicked.
An alternate way would be just to have two views (left and right) and implement a View.OnTouchListener to determine where the click occurs by looking at adjoining pixels: their color and placement.
Good luck!

How do I make a view expand like a Material "sheet"?

I have a card-like view with elevation and a white background that I want to expand to fill up the whole screen. It's a card in a list (my own custom layout, not a CardView), and I want to make it take up the whole screen when it's tapped via a Fragment transition.
My first idea is to create a fake, identical view in the new fragment, place it at the item's position, and animate it to the top, while animating its layout bounds to take up the whole screen. However, I don't think this is the best idea, as Android will have to remeasure the layout every single frame while the animation is running (likely to lag). Is there a way I can get this effect in a clean way? I'm going to be using fragment transitions, so hopefully I can use Animator in some way, but I'll take any solution.
You can try to do the same, but instead of relayouting, do redrawing. Create custom implementation of view's onDraw(), it's not that hard.
View will fill entire screen but at the start of animation will draw only initial part.
Or you can just try your approach, it's easy to implement and may be it is not that slow.
Also, may be directly modifying view's setLeft(), setRight(), etc. with Animators is a valid solution.

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.

Controlling Z-Order of Custom Drawn View ON TOP of a SurfaceView

I was having some issues having a view on top of my surface view. I followed the instructions on this answer: https://stackoverflow.com/a/2934759/1315692
That worked great EXCEPT for a view that is custom drawn.
The custom drawn view ALWAYS remains on top. What do I need to do to be able to put a view on top of it? Thanks for any suggestions or insights.
I figured out a solution. It may not be the best solution but it is working for me.
I drew my view that I wanted on top in the draw routine of the object that was stubbornly staying on top USING THE SAME CANVAS. I added a field of type View to my SurfaceView (because that is where the view that remained on top is drawn) with a setter. Then in my draw routine I simply called passedInView.draw(canvas);
If you are at a point where you are not drawing on top of the surface view at all then start with the link from my question. That should be all you need. This is for a situation where a custom drawn view still remains.
Now this can cause some undesired behavior in regards to tapping (you can tap right through your on top view)...so you will need code to handle that but if all else fails, as it had for me, this got my view on top.

Categories

Resources