How to set the initial position of a BottomSheet? - android

Is it possible to to have BottomSheet initial position start from approx. middle of screen? instead of having at end of screen?
How can I set that initial position? I want BottomSheet (that has a recyclerView in it) to appear initially from middle of screen (towards bottom). When user swap it up, it should come up and stop just under my app main Title bar.
Your expert opinion is appreciated.

Related

Is it possible to customize the snap behavior of `ViewPager2`?

I need to emulate the behavior of Instagram's Reels which scrolls to the next or previous page when the current page is scrolled more than 50% upwards or downwards respectively and the finger goes up. ViewPager2's default behavior isn't satisfactory for this and I don't think I can change it without changing the PagerSnapHelper inside ViewPager2.
Is there any other way I can implement a custom Snap behavior for ViewPager2 then?

how to control Android ScrollView to go all the way to top or bottom but never middle?

I have a fragment with a scrollview that holds a long layout essentially representing 2 different sections that are related, what I want is to control the scrollview so when the user wants to scroll down it always goes all the way down and can never be in the middle so it will never reveal partially the top or bottom parts, same effect backwards when you want to scroll up it just takes over and goes all the way up to reveal the top section of the layout fully.
It is basically how a vertical viewpager will behave but contained within a single long view.
I know how to programatically scroll up or down but I don't know how to avoid the user scrolling to just the middle, I'd like to hook up to some scroll event, detect the direction and go fully in either direction.

Translate overlapping Views on scroll with different speed

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

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

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