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/
Related
I have a recycler view below my appbar, and it expands when I'm at the top of my RV and I scroll up one more time. I need my collapsed toolbar to expand when the smooth scrolling animation reaches the top, so I don't need to scroll up again. Instead what I get is that I scroll to the top, and my RV stops, then I have to scroll again just to expand the collapsed toolbar.
I am currently looking into MotionLayout, because in this answer I've read it offers easier behavior customization https://stackoverflow.com/a/55328600/13150066
I don't know how to upload videos here, but if you have an idea and want to check out the behavior I want, check out spotify's playlist.
Is there a solution to my problem so I don't have to change to MotionLayout?
I had to take a look at those MotionLayout and it's super easy. Made it work!
I downloaded Android Studio 4.1 so I could use the new layout design interface and it work wonders. Honestly I thought it was going to be really difficult to achieve, this effect, but it was really simple, and everything is pretty self explainatory. Anyways, I'm leaving you the tutorial I did it with, hope it helps!
https://blog.stylingandroid.com/motionlayout-collapsing-toolbar-part-1/
I think the most beneficial part of using MotionLayout is that it extends from ConstraintLayout, so your Layouts are laid flat. No Collapsing Toolbar inside an AppBar, with a Toolbar and an ImageView nested. Using MotionLayout, I only used an imageView laid flat and the animations are set in a new XML.
In google play app, you would have seen when when we do scroll up action any where on screen, upper branding area moves slowly and the content section moves faster rate. how can this be achieved?
i though of one option: will add two views full screen inside relative layout, in top view will give margin top of some value and background is transparent.
will add scroll listener and on scroll action of will animate the bottom view at slower rate.
will this be proper way or does better way exists?
Regards.
Try this library it has lots of types of actionbar animations
Excuse my terrible paint skills, but that's a picture of my proposed layout.
I would like the blue part to be a RelativeLayout. Underneath the blue RelativeLayout is a ViewPager with Tabs, each tab containing a ListView.
What I'd like to do is be able to hide the blue layout as the user scrolls down the ListView, and reappear as the user scrolls up to the top of the ListView.
How can I achieve this?
Please have a look at this library ParallaxScroll
It very easy to implement and it supports both scrollviews, listviews wtc
I use the following to browse for new libraries etc..enjoy :D
You need to use lockable scroll view by this you can put your whole layout into it and lock the scroll at the specific location points on the screen
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));
I have a ScrollView layout like this, for example:
<ScrollView>
<Component1>
<Component2>
<Component3>
<Component4>
...
</ScrollView>
Inside ScrollView I have some components, each of them can be anything like LinearLayout, RelativeLayout, TableRow, ...
Now what I want is I will scroll the view, when the <Component2> reach the top of the screen, it will be keep on the screen and <Component3>, <Component4>... will keep scrolling till the end of page. When I scroll down, <Component2> will only be scrolled when all the <Component3> has became visible. I saw this on an Iphone app and wondered how to achieve this on Android.
I don't know if I describe clearly enough but it is same like this video
http://www.youtube.com/watch?v=jXCrM1rzLZY&feature=player_detailpage#t=71s
When the tabs scrolled up to top, it stay there. And when scrolled down like in 1:36 of that video, it stay there until all the content below has became visible on the screen.
Does anybody know how to do this on Android?
I guess you could create a hidden copy of Component2 in a RelativeLayout that is setVisible(true) when the coordinates of Component2 are lower(Android draws from the top) than the top of the ScrollView. When the coordinates of Component2 are higher than the top of the ScrollView (.getTop()), Component2Copy.setVisible(false).
You may also want to disable them when changing their visibility. Good luck with this.