Comments (2)
Hi,
i had the same problem. The onClickListener is obliviously interfering with the touchListener of the library, so i guess you can't have both. Fortunately you can use the touchInterface provided by the PhysicsLayout library. Just use the "touchEvents" to identify a click yourself. One way could be to track the time difference the user grabbed and released an item. If its shorter than a certain threshold its considered a click. To improve this you could also track the position of the grab and release and if it exceeds a certain distance its not a click anymore. I hope this helps.
physicsRelativeLayout.getPhysics().setOnFlingListener(new Physics.OnFlingListener() {
private static final int clickTimeDeltaInMs = 150;
private long grabStarTime = 0;
@Override
public void onGrabbed(View view) {
grabStarTime = Calendar.getInstance().getTimeInMillis();
}
@Override
public void onReleased(View view) {
final long grabReleaseTime = Calendar.getInstance().getTimeInMillis();
if((grabReleaseTime - grabStarTime) > clickTimeDeltaInMs) {
System.out.println("no click");
return;
}
//do stuff – its a click
}
});
from physicslayout.
Awesome! That worked perfectly for what i was trying to achieve! Thanks a lot man :D
from physicslayout.
Related Issues (20)
- Can I Change the Bounds' restitution? HOT 1
- Hello, ask the next question HOT 1
- Problem with joints
- Circular bounding layout HOT 3
- Is there any way views/childs in layouts can move according to accelerometer values HOT 1
- How to update radius of already added view HOT 1
- Performance issue when I add more than 10 views HOT 2
- Too fast to the edge, the figure will disappear HOT 5
- problem with the layout HOT 11
- How to use fling=true in a scrollview?
- Is there a way to make views not draggable or add views that don't have physics enabled?
- Difference between the sample on Google Play and sample on github HOT 1
- drag & drop object
- set "layout_fixedRotation" dynamically
- Physics freezes after all child views finished movement HOT 4
- Jetpack Compose Version (Simplified) HOT 1
- After 2 minutes very laggy
- Is there edge detection?
- I can't dynamically add a child layout via addView, it crashes! HOT 2
- Question about the inconsistency between the number of child views added and the number actually displayed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from physicslayout.