What is the marked thing called ? (android swipe disabled effect) - android

I'm trying to find something about it and the API level of it.
It's only visible when the user reaches the end of a tabbed, swiped activity

Check out https://developer.android.com/reference/android/support/v4/widget/EdgeEffectCompat.html, it's used in ViewPager internally.

It's an android attribute called fadingEdge. Many of the android widgets like listview, viewpager, scrollview etc use it by default. You can place it in your widgets too using android:fadingEdge attribute.
Regarding the api level, it's deprecated since API 14 but you can still use it by requesting it using android:requiresFadingEdge attribute.
Refer to the docs here for details.

This is what I found in the Android documentation:
You can use scrollers (Scroller or OverScroller) to collect the data
you need to produce a scrolling animation in response to a touch
event. They are similar, but OverScroller includes methods for
indicating to users that they've reached the content edges after a pan
or fling gesture. The InteractiveChart sample uses the EdgeEffect
class (actually the EdgeEffectCompat class) to display a "glow" effect
when users reach the content edges.
Link: https://developer.android.com/training/gestures/scroll.html

Related

How to scroll scrollable AccessibilityNodeInfo nodes

Using Android 4.2.2
I'm trying to write an AccessibilityService, and have most of the required features. I'm drawing on an overlay and allowing the user to select/cligk highlighted items via a bluetooth switch (the purpose is a disabled client wanting to interact with an android device using only one switch).
Whilst parsing a screen, I can get the root accessibiltyNodeInfo object, and all its children. I can highlight on the screen all such elements, and click a desired one by the .performAction() method.
On the home screen, there are 3 "panes" available, with the middle one being shown. Swipe left or right to see the others (standard launcher behaviour). There is a node that reports isScrollable = true, but the Action Flags do not report ACTION_SCROLL_FORWARD or ACTION_SCROLL_BACKWARDS. How do I scroll such a node, if I cannot call .performAction() on it as it does not support scrolling? Why does it report isScrollable = true if its not somehow scrollable?
Any help appreciated - thanks.
You cannot scroll a node that cannot perform ACTION_SCROLL_FORWARD or ACTION_SCROLL_BACKWARDS.
The Accessibility framework on Android is experimental at best and is plagued with inconsistencies such as the one you mentioned. In general, it is best not to rely on any of the is[Property]() methods. Instead, you should test for the property you are interested in yourself, after calling getActions() or getActionsList() on the node.

Swipe to confirm layout in Android

Helo,
Is their any library that supports the swipe to delete feature as implemented in gmail on Android, that also shows the undo button ? I saw this also on google io 2013, so i assumed this is natively supported by Android ? Is this so ?
Kind Regards
yes there is but you need to slightly modify those based on your need:
https://github.com/romannurik/Android-SwipeToDismiss and this https://github.com/timroes/SwipeToDismissUndoList
and this https://github.com/47deg/android-swipelistview
There is no library i guess. But u can implement it by using DragListener and making the view's visibility to gone (make a custom view by extending it). And when you undo, set the Visibility to "Visible"
You can also use OnTouchListener and listen to the co-ordinates on which user performs drag & then perform your logic.

Analogue of android:filterTouchesWhenObscured for API level below 9

Starting with API level 9, there's android:filterTouchesWhenObscured attribute and corresponding setFilterTouchesWhenObscured method on ViewGroup. For example, when a view has onClickListener set and another view obscures that view (e.g. an overlay panel, a toast, or anything else), then touches will not be passed to the obscured view - in my example, onClick will not be fired.
However, this is not available in API level 7 - and for my project the requirement is Android 2.1 and above, which means I have to work with level 7.
Is there an easy way around it? In level 7, this property is essentially hard-coded to FALSE. As a result, I get this strange behavior: on a view, I have a button. When pressed, another view slides into place, covering the view with the button. On this view, there's its own button, but it doesn't match the location of the button underneath. Therefore if the user touches the overlay panel in the location where the button underneath is, the onClick of that button is fired again - not what I want/need.
What can I do to prevent onClick firing in this case? Thanks.
Turns out, there is no way of doing it. In Android prior to API level 9, there are two ways around the problem:
Remove listeners from the underlying views (in my case, I have about a dozen of them, which I would need to remove and then re-set after the overlay is made invisible again); or
Add an empty onClickListener (i.e. intercept the click event and do nothing on it) on the entire overlay - this is the way I'm handling it in my case.
Interestingly, the behavior of an obscured view receiving click events was reported as a bug in an earlier version of Android, but that bug was closed indicating that it's not a bug but an intended functionality instead (I can't see why anybody would want that functionality though). I suppose the android:filterTouchesWhenObscured attribute was added in level 9 to appease all the unhappy developers out there :)

How to implement Android 4.0 like swipe to dismiss functionality in ListView?

I'm working on an app in which I would like to implement swipe-to-dismiss functionality in the ListView - similar to what we see in Android 4.0's notification bar, recent apps list or browser tabs. I want to run the app on the devices running Android 2.2+. See the following image. I also want to change the transparency of the item being swiped-away - just like in ICS.
I checked the source of the ICS web browser on http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.1_r1/com/android/browser/TabScrollView.java?av=f but couldn't figure out which class is particularly responsible for implementing this functionality.
Can anyone point me in the right direction here? Can we do this using Android Compatibility Library? Please let me know. Many thanks.
I've thought about implementing such a feature as well, but I haven't done it yet. So the only thing I can provide are some ideas on how I would approach that problem. If I've eventually written some code I will post it here.
The main class needed is a custom Adapter which extends a ListAdapter (ArrayAdapter, SimpleCursorAdapter etc.).
The adapter applies a View.OnTouchListener to all of its Views.
Whenever that listener detects a horizontal scroll dx, it calls concernedView.offsetLeftAndRight(dx) (which will make the view draggable). Of course the adapter has to save the current horizontal offset for the view. If the user was dragging a view and removes his/her finger from the screen, the touchListener will detect this as well and start a slide back animation. Using the current offset we can also calculate an alpha value, so the view will fade out when it approaches the screen borders.
If one list entry is eventually dismissed by the user, it becomes a bit tricky, and I'm still not sure how I would implement the following action: The list content has to be updated (or the adapter has to ignore the dismissed entries) and the views that were below the one that was dismissed must hover upwards in order to fill the gap. I think it might work to let the ListView load the new content, but that would fill the gap instantly. In order to avoid that, I would then start an animation that lets all the concerned views hover from their old position (where we still had the gap) back to their current position (where the gap is filled).
These are just some of my thoughts on the issue that might help some people getting started on working on the problem. Like I said, I'm probably going to implement that sometime in the future and of course I will post the code here.
I would appreciate any feedback in the comments, but I don't want to thorougly explain every single aspect of my idea, that would take me too much time ;)
I know this is quite an old question, but for anyone still searching for this, you can have a look at Roman Nurik's library here: https://github.com/romannurik/Android-SwipeToDismiss
This shows how to create the required behavior for list-view as well as for normal views.

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