I need simplest way to implement a sliding overlay panel for my app.
Here is what I want to do:
I have a grid view of images in my main activity, when user clicks a Image a sliding overlay drops from top of screen to up to half way showing details of Image and partially hiding contents of grid view, I have searched quite bit and found these articles;
Using FrameLayout,
SlidingUp Library
Using fragments
but I do not want to use a library for this simple task as it may be a overkill.
So can somebody please share some example to implement it using Framelayout or fragment in minimalistic way possible.
Create a RelativeLayout that has a view that's outside of the screen and move it with an ObjectAnimator that sets the view's translateY property.
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(yourLayout, "TranslationY", 200 );
objectAnimator.start();
This will animate the move of the layout container.
You can use this
https://github.com/jfeinstein10/SlidingMenu
If you are using Actionbar then you can use this code:
setTheme(theme.whatever);
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
setContentView(R.layout.content);
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.color));
Related
Look at this video: https://ibb.co/37V0Vgt. I wanted to create a activity with the bottom view(in the video) which you drag up and down. The view also snaps in two positions.
when it is fully expanded
all the way down
I have been searching for a way to create this kind of view but have found nothing. The problem is if you have a view at the bottom how can you expand it up just like in the video.
What I want is a solution on how to implement this kind of view. You would add it to the bottom of your activity layout and behave exactly like in the video. Is this something which already exists? Then what is it called?
This is a Botom Sheet. You can place a layout inside a CoordinaterLayout and apply the BottomSheetbehaviour to it to create this view.
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
You'll require the Material Components Library as stated here.
In your video, the Bottom Sheet is in the STATE_COLLAPSED state and can be pulled out.
I am trying to implement an application intro something like in the attached gif.
I know Shared animation isn't supported in Viewpager but I really need to have something like that.
Any help would be appreciated.
One way would be to draw the animating view in top of view pager using framelayout. And then animate it using scale animation and translate animation when view pager moves..
I am answering my own question just to help others who are looking for the same.
I have found the library for such kind of animation. Below mentioned is the github link
https://github.com/IFTTT/SparkleMotion
However, I used the suggestion given by PrafulBhatnagar and used some overlay views while hiding the actual page views during the viewPager's scrolled/fling state.
I need to show a view sliding up for all my pages(fragments). Just like navigation drawer working. I don't want to include layout in every view and animate. Please suggest a solution
Create a common base class that your fragments extend from. What is the purpose of the sliding view? Does is just animate a scroll within a fixed space? Does it move above it up when it animates in? Does it overlay over the view as it slides up? Need more clarification.
You can use something like AndroidSlidingUpLibrary.
I'd avoid using it for scrolling views, it is nice though.
I am working on a pdf reader application. When the user touches the screen, two toolbars will slide into view, overlaid on top of the pdf. There is one toolbar at the top of the screen and one at the bottom, that slide in from off-screen when touched. What is the best way to go about implementing this? I've been having trouble finding any code examples for something similar. Thanks for your help.
Put your PDF viewer inside a RelativeLayout setting match_parent for layout_width and layout_height. Then add your toolbar to that RelativeLayout setting the toolbar to layout_alignParentTop="true" will make sure the toolbar is on the top of the container. Then you can slide the toolbar in and out of the view using a TranslateAnimation between -1.0 and 0.0 for slide down, and 0.0 to -1.0 to slide out. You may have to set the visibility to GONE when the animation completes for sliding out of view.
I wrote a post some time ago about how to implement this kind of full screen with top and bottom bar. Maybe it's useful for you:
http://miguelrodelas.com/web/2011/12/17/full-screen-in-android/
What I am trying to do is to have a menu appear over listView. Just like in okCupid app :
when you click menu below the picture :
https://ssl.gstatic.com/android/market/com.okcupid.okcupid/ss-480-3-11
it extends itself over the background view :
https://g1.gstatic.com/android/market/com.okcupid.okcupid/ss-480-4-11
I have a feeling that this particular app is done in Sencha or JQuery mobile or similar technology but is it possible to get same effect in native app?
thanks
Most layout classes 'help you' by avoiding widgets to overlaps, but with the RelativeLayout you have more flexibility to create overlapping views.
To be sure the overlay view is on top, you can call ViewGroup.bringChildViewToFront() on the relative layout.
In your example the top view also has a partially transparent background.
Try using FrameLayout and add appropriate transperency for the view
I can look around for some example code later but the basic idea would be to have a MenuView class that draws your menu and animates in and out by setting the content of the menu visible or not.
Then just have all your content be on top of that MenuView by using the relativelayout align_parentBottom and set the content to above the menuview.