Closed AmarokStudios closed 6 years ago
First of, when I have onClick events added to an element, this overrides the panning ability. When an onclick listener is on an object (in my case an ImageView), I can't scroll when clicking on the similar area (this is an issue because my activity has a lot of these that cover most of the view-port).
Yes, sometimes this is desirable, but other times it's not. In that case, you can use TileVierw.setOnMarkerTapListener
. From the README:
Markers can have traditional touch handlers, like View.OnClickListener, but these usually consume the event, so a drag operation might be interrupted when a user's finger crossed a marker View that had a consuming listener. Instead, consider TileView.setMarkerTapListener, which will react when a marker is tapped but will not consume the event.
The other issue is, when an element has an onclick listener, zooming out puts it in the wrong place. For example, if I have an image view in the center of the screen with an onClick listener on it, then zoom out, it no longer registers at the center, it registers somewhere in the bottom right of the screen instead.
That's correct. If you're adding Views
manually, you'll lose everything but pixel position - again, I'd refer you to the README. You can get around this with the same thing above - markers and marker listeners - or you can use the HotSpot
API.
HTH, GL
Thank you for the quick response. I tried using a marker but still seems to be consuming the event, preventing panning.
tileView.addMarker( r1, 250, 500, -0.5f, -1.0f );
tileView.setMarkerTapListener(new MarkerLayout.MarkerTapListener() {
@Override
public void onMarkerTap(View view, int x, int y) {
plotManager(10, tileView.getScale());
}
});
I apologize if it's something I'm missing but panning is still disabled.
Does it happen in the demo?
No it does not. I will look into the demo code again to see if I can identify the bug. Thank you for all of your help and great job on the library! I will update when I get the solution or if I can't get it lol.
Sounds good
Okay I'm back with a quick question. Is there a way to make the markers scalable? I need the ImageViews to scale with the TileView? I'm trying the Hotspot but it's giving me an error using the code in the README. It's saying the first parameter of the addHotSpot method need to be a List<double[]> instead of a HotSpot instance as defined in the example.
HotSpot hotSpot = new HotSpot();
hotSpot.setTag( this );
hotSpot.set( new Rect( 0, 0, 100, 100 ) ); // or any other API to define the region
tileView.addHotSpot( hotSpot, new HotSpot.HotSpotTapListener(){
@Override
public void OnHotSpotTap( HotSpot hotSpot, int x, int y ) {
Activity activity = (Activity) hotSpot.getTag();
Log.d( "HotSpotTapped", "With access through the tag API to the Activity " + activity );
}
});
The goal is to have an ImageView that scales with the rest of the TileView, with an onclick listener that doesn't disable panning when dragging. Any suggestions?
Good afternoon @moagrius ,
I've been unable to find a way to get markers to scale (I know they aren't designed to). Would you happen to have any ideas on how I could manage this? I'm loving your library so far. Very useful.
I'm trying the Hotspot but it's giving me an error using the code in the README. It's saying the first parameter of the addHotSpot method need to be a List<double[]> instead of a HotSpot instance as defined in the example.
Check the source. There is a method for addHotSpot(HotSpot);
https://github.com/moagrius/TileView/blob/master/tileview/src/main/java/com/qozix/tileview/TileView.java#L604
You're trying to use the convenience method that takes a HotSpotListener
as a second argument. You don't have to do that - you can add listeners manually. Again, I'd suggest reading the source for most of this stuff.
I've been unable to find a way to get markers to scale (I know they aren't designed to). Would you happen to have any ideas on how I could manage this? I'm loving your library so far. Very useful.
It's certain possible, but consider that if you have a marker with a clickable icon, a clickable header, and a close button, every time the scale changes (very rapidly in a pinch or animation), the View system will have to re-layout all those elements for each marker every time.
If you want just one click listener per marker, use HotSpots as described above.
If you just want to scale pixels (not actual layouts, hit detection, etc) you can use the techniques described in the docs, or you can scale them yourself (there's a scale change listener - just scale them manually with View methods, or a third party library, etc).
There's a lot of ways to do what you're describing, but nothing built in, and the best approach is going to depend on what you want to do exactly, and it's probably not going to be answers specific to TileView, but rather to AOSP as a framework.
HTH, GL
Great, thank you for all the help. I apologize if they were some dumb questions. Keep up the great work! I really appreciate this library!
NP, GL
Good afternoon,
So far I am loving this library. It's enable me to work on a project I've been wanting to do for a long time. Unfortunately, I'm having some pretty major issues which is causing some problems.
First of, when I have onClick events added to an element, this overrides the panning ability. When an onclick listener is on an object (in my case an ImageView), I can't scroll when clicking on the similar area (this is an issue because my activity has a lot of these that cover most of the view-port).
The other issue is, when an element has an onclick listener, zooming out puts it in the wrong place. For example, if I have an image view in the center of the screen with an onClick listener on it, then zoom out, it no longer registers at the center, it registers somewhere in the bottom right of the screen instead.
Please help! If you could fix this, this would be the best library here on GitHub!
Thank you, Tim