I am trying to make sliding drawer menu like the one in the YouTube app. I navigated many questions like this amazing one here. and found a lot of libraries but all of them slide from left to right or from right to left in different one. I want to make it slide from both sides, left to right and right to left via two buttons in the top bar.
You can look at github.com/Ali-Rezaei/SlidingDrawer, which mekes it possible for you to slide from any side.
Use Yahoo Rangeseekbar
The package is
com.yahoo.mobile.client.android.util.rangeseekbar
It will let you slide both the sides and you can choose if you want to display the values on the top of the slider min and max ends.
You can use the standard DrawerLayout from the support library. As it says in the documentation, you can control the placement of the drawers with the layout_gravity attribute. From the documentation:
To use a DrawerLayout, position your primary content view as the first child with a width and height of match_parent. Add drawers as child views after the main content view and set the layout_gravity appropriately. Drawers commonly use match_parent for height with a fixed width.
Related
I have a project with 99 fragments. A client wants us to make our BottomNavigationView semi-transparent and have our content scroll behind it. But not all our fragments are scrollable. Some are RelativeLayouts with controls attached to the bottom of the page that need to not allow themselves to go down past the BottomNavigationView, so that they're not covered up. And even with the pages that scroll, sometimes it's not even the entire page that scrolls, but just a subset of it. Is there any way I can achieve this kind of ambiguity without going through all 99 of my fragments and making a unique judgement call on each or them?
There is no direct solution as such for what you are trying to achieve.
If your fragments has RecyclerView then add extra bottomSpacing for last item in the list in ItemDecoration class.
If your fragment has ScrollView then add extra paddingBottom for last view in the hierarchy.
If your view has anything other than these two scrolling views, then you can hardcode the bottom margin and give a color below matching to the navigation view. This make it look opaque from translucent.
One thing that is understood is the bottom spacing, margin and padding will be equal to or slightly greater than (ideally height + 8dp) you bottom navigation.
Since you fragments behave differently, there is no use of trying to make single solution for the same. But to make the job easier for future, you can externalise these margins and spacings in dimens.xml (use same object for all the spacing) and hence in future if any requirement changes, you can change the spacing directly from the dimens.
And you can do the same for bottom navigation spacing color, externalize to colors.xml and change it as you like.
I am trying to create an activity layout with two parts, where their respective size is dynamic. The activity should have two states:
Starting state:
The user scrolls the bottom part up to the second state (and back):
It's important that the change will be animated. I tried a few solutions so far but didn't manage to find the exact way to do that:
AndroidSlidingUpPanel - The panel acts as another layout, covering the upper view and moving the toolbar out of the screen.
Android Split Pane Layout - Correct behavior, but the splitter is dragged and not the bottom part (I don't want to have a visible splitter).
CoordinatorLayout with CollapsingToolbarLayout - I didn't find a way to limit the upper part from totally disappearing. Anyway I think that it's a bit abusing because I don't want to collapse a toolbar but just change the children's height with animation.
Is there a good way to implement this using another library, one of these that I perhaps didn't use correctly or with simple layouts? Thanks!
I found a custom version of the SlidingPaneLayout created by VLC, which is basically a vertical SlidingPaneLayout - the exact functionality that I was looking for.
In my application I want to have sliding menu on the left side just like facebook.
In my previous question I had raised concern regarding the same and thanks to this answer that I could found a way to slide my layout to right using this library. But, I found that, the library does not actually slides the layout, instead it just takes the screenshot and slides the image towards right as the components on the layout are not clickable. And I need those components to be clickable. So, I tried a new way of achieving this by putting the slideout menu on the left by keeping its default visibility to View.GONE and make it visible on click on left top corner "Show/hide Menu" button as shown in figure below.
Layout before:
Now when I click "Show/Hide Menu" button, the layout is something like-
Layout after:
As you can see, the layout on the right shrinks and so the button "Some other view" changes its width even if I've set the android:minWidth attribute to those two buttons on the right as well as its parent RelativeLayout.
So my question is, is there any way to shift the layout towards right without the inner components changing their width/layout? So in whatever area is available for my view, it will be filled by whatever portion of the content that can be filled in in that area.
This problem can be solved like this:
create framelayout with inside: first left menu with 3 buttons and second layout that contains other two buttons (show/hide and other view). This way, the second layout is in front of menu (since it is fill_parent).
in onClick of show/hide button perform translate animation: assuming that your menu is 200px wide, move the second layout by 200 to the right.
in onAnimationEnd, set margins to the second layout like this: secondLayoutLayoutParams.setMargins(200, 0, -200, 0);
Closing menu is similar: move the second layout to the left by 200 and set all margins to 0.
By setting margins you will avoid button shrinking.
Hope it helps
#Rajkiran - I have a root layout, that contains my left & right layouts.
My right layout has layout_height set to 'match_parent' & layout_widht is also set to 'match_parent'
Now when my left sliding panel appears on button click, I reset the width & height of my right layout programmatically to match the width & height of the root layout.
This perfectly shifts the right layout towards right without the inner components wrapping up.
To change height & width programatically I used this -
rootLayoutParams = new LayoutParams(rootLayout.getWidth(), rootLayout.getHeight());
rightLayout.setLayoutParams(rootLayoutParams);
Hope it helps you as well.
I want to create sliding drawers which comes from right to left which has two handles for loading different contents. Handles position should be in between center and bottom of the screen, so that whenever I slide with any handle, application should show the corresponding content on the whole screen.
I checked earlier sliding drawer's questions and solutions, but could not help to my scenario.
By default slide drawer's handle position is centre right to the
screen. And when I place two handles, second handle is over-lapping
the other, and I can see only one handle.
Tried keeping PaddingBottom as 200dp. Now I could see both the
handles, but second slide drawer's content is shown for both the
handles.
Kept slide drawers inside linear layout, and assigned layout_weight
as 1 for both slide drawers. With this, complete screen is divided
into two equal parts. But I want to use whole screen for each handle.
Could someone help in this regard.
Thanks in advance.
The sliding drawer can be placed in a frame or relative layout according to the developer's site. And you can set the top offset for your layout inside the layout present in the drawer which is in the xml. Hope it works. Worked fine for my code.
I would like to position an element of an activity's layout relative to the top of a sliding drawer handle in its closed state. The standard Layout above relative layout attribute obviously doesn't work given the floating nature of sliding drawer.
It seems to me that the only (non-programmatic) alternative is to bottom-align and used fixed margins or bottom padding to ensure the element sits above the closed sliding drawer handle. This approach is pretty crude and I'm hoping to avoid this because I would like the sliding drawer handle height to be dependent on its content (which is dynamic).
Any suggestions to help achieve a more fluid layout?
You can control the height of the sliding drawer if you want to and I think that is the case with this question. The sliding drawer is just taking some space of the screen and other content should be above it
Can't you use a LinearLayout (Vertical), and set its position to bottom-align