Open Percentage of SlidingDrawer in Android - android

I am trying to determine the "open" percentage of a SlidingDrawer in Android. It seems that the drawer only has onOpen, onClose and onScroll Listeners. OnScroll only provides methods for determining when scroll has ended and when scroll has begun.
TouchEvents won't work either because the SlidingDrawer can slide without being touched...
I tried grabbing the Animation of the SlidingDrawer using getAnimation() (and then somehow determining percentage based on that) but that returns null and so does getLayoutAnimation().
Any thoughts?

Very late answer, and I'm sure you don't care anymore, but someone else might. :)
I'm not entirely sure why you want a sliding drawer at all. It is likely easier and faster to write your own custom view that allows you to slide in and out, than to try to use sliding drawer. That way you will have way more control.
Another thought is to try getting the visible child rectangle of the sliding drawer from its container using getChildVisibleRect, and calculate the visible percentage using getWidth on the drawer. I'm not at all sure this will work. :)
Best of luck either way.

Related

Non-sliding content and action bar using SlidingMenu library

I am using Jeremy Feinstein's SlidingMenu library to implement a sliding menu on the right.
Is there any way to make the menu slide out without displacing/pushing the content view to the side? Currently, when the menu slides out, the content also gets pushed towards either the left or right (depending on which direction the menu is coming out from). I would like to make an implementation where the menu appears from either the left/right but "sits on top" of the content view (content view never moves, the menu view literally flies in and out).
Ive been digging about but there doesnt appear to be a simple function i can call to enable this. Do I have to implement it myself or am I missing something?
Time to answer my own question! :D
It seems that after looking through the source code of Jeremy Feinstein's SlidingMenu library, what happens is that the library actually "extracts" out our view and then somehow join it together with the sliding-out view. After that, the views are merely scrolled around (I could be mistaken, but i know the extraction of view does occur. As for the way the library accomplishes the scrolling and sliding, i didnt look into it too much.).
So, the answer to my own question is : No, it cannot be done by the library. No simple function available (due to the way the library achieves the sliding effect).
In the end, i opted to use a framelayout with overlapping views. One visible, the other invisible. Then i just change visibility and animate the views.

Making a slidable view from top to down, similar to the one in Android

The idea I'm having is having a view that can be pulled down on top of the current view, with similar animation features like the one you can pull down from the top all the time, on Android Devices.
Here's an illustration:
The idea is to grab it and being able to pull it down on top of the other view, and then being able to interact with that view. To slide it up again, you should grab the bottom of the view (the grey area in the illustration) again, and then pull it up.
I haven't even worked with animations before but I found a lot of topics on that, while searching for solutions to my problem, including this: Slide down view in android
but my impression is that, that is about making animations when the user isn't touching the phone.
What is the best way to do this?
Is there a better way to do something very similar?
EDIT:
Here's the topic that made me find the solution: How to make an Android SlidingDrawer slide out from the left?
And here's the solution I used:
SlidingDrawer Top-to-Bottom
You could use a SlidingDrawer, this is a built in component into Android, but as far as I know it slides only from bottom - up.
If you a comfortable to modify your app design, then this could be an option for you.
However, on internet are some libraries of custom SlidingDrawer that lets you put the marker on any side of your screen, so you can drag it top-down, left-right, right-left.. any way you want.
Useful links:
How to make an Android SlidingDrawer slide out from the left?
SlidingDrawer Top-to-Bottom

How to make a sidebar menu

I'm looking for a way to develop a menu which could be visible by sliding on the left of the current screen. One example is the mobile version of Firefox, when you slide on the left, you can access to the current tabs navigation, but the main page is still visible. It is called a sidebar I think :
EXAMPLE
One possible way to do that is to use ViewFlipper, I guess, but maybe is there an easier and more efficient possibility ? And I'm afraid that handling scrolling horizontally and vertically could be a bit difficult...
Thanks for any answers,
Maxetx.
Maybe this will give you an idea
https://github.com/korovyansk/android-fb-like-slideout-navigation
https://github.com/walkingice/gui-sliding-sidebar
You may try out SlidingMenu. There is example in lib.

ExpandableListView Slow expanding

How can I increase the duration of expand action in expandableListView in android
In my code when I call
expList.expandGroup(gp);
it expands very quickly ... I want it to be expanded slowly to appear as if it is sliding
Any suggestions?
I think that this question is similar to yours and therefore may be of use to you. It seems like the right approach to take is to look at it as an animation, in which case the answer to the above question would apply; it also seems (unfortunately) that the easiest way to do it would be using a regular ListView and handling the expansion and animation yourself.

How to implement swipe pages [duplicate]

I'd like to make a view in my Android app that flips between multiple views on a swipe/fling. I'd like it to behave more or less like the Android Launcher behaves when flipping between views. In particular,
It should flip views on swipe.
Generally a swipe will flip between one view and the next. It should not fling across all of the views.
If you swipe slowly, you should see the views dragging as you're swiping, eg. the way the Launcher does it.
I tried using a ViewFlipper with a GestureOverlayView as per Romain Guy's blog post here, but there's no indicator to the user as they're swiping. This makes discoverability difficult, which is presumably why Launcher does it the way they do.
I tried using a Gallery object, but when I swipe from left to right, there's a certain amount of momentum that flings the users through all the views rather than just taking them to the next view.
Is there a good way to accomplish what I'm trying to do?
I know this is an old question but ViewPager is created for this exact same purpose. ViewPager is part of android compatibility package and more can be found at http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html
Take a look at HorizontalPager. It's actually based on RealViewSwitcher, which in turn is based on the Android homescreen's code, and supports snap-to paging with drag feedback, as well as nested vertically-scrolling subviews. Gesture support for fast swipes isn't all it should be, but this may get you part of the way there (and I'd welcome contributions back).
EDIT: As of 2012 you're much better off using Google's ViewPager - it's in the compat library.
Check out SwipeView within this project https://github.com/fry15/uk.co.jasonfry.android.tools It does exactly what you want it to do and is super simple to implement.
#CommonsGuy extended ViewFlipper to do it.
https://github.com/commonsguy/cwac-viewswiper
Ihaven't used this one yet so im not sure if it moves with your finger like the launcher if not your going to have to make an OnTochListener to do it for you in me.ACTION_MOVE you will update the view to change its position. I'll post some sample code when I get home if you don't get another answer.

Categories

Resources