New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image got invisible after dragging other view #51
Comments
@dharmendra2012 I could not repro your issue. I tried by setting up a RelativeLayout and placing one TouchImageView on top of a second TouchImageView. I could zoom and drag both without either disappearing. Are you sure that the issue is only with dragging views over the TouchImageView? Could it be something else? #48 and #41 caused a similar issue where the TouchImageView would disappear. Could you test with the latest changes in the dev branch? |
Hello, First of all, thank you @MikeOrtiz for TouchImageView! I've been using it a lot. I might have the same issue as @dharmendra2012 though, and I might know why it happens. I'm using the latest dev version: https://github.com/MikeOrtiz/TouchImageView/blob/dev/src/com/example/touch/TouchImageView.java The problem: I have two elements in a LinearLayout. First a TextView with android:visibility="gone" and under this the TouchImageView. The problem then appears when I programmatically change the visibility of the TextView from "gone" to "visible". This causes onMeasure(int widthMeasureSpec, int heightMeasureSpec) in TouchImageView.java to get called, but the problem is that savePreviousImageValues() isn't called before this, meaning float prevActualWidth = prevMatchViewWidth * normalizedScale;
[...]
float prevActualHeight = prevMatchViewHeight * normalizedScale; in fitImageToView() both become 0. Thus making the image disappear. To get it back you have to pinch zoom out all the way as mentioned in #41 On the other hand, if you rotate the phone onConfigurationChanged(Configuration newConfig) gets called, meaning
also gets called. And then everything works. If I first rotate my phone, and then change the visibility of the TextEdit the TouchImageView doesn't disappear. But this is obviously no solution. I'm not really sure where in TouchImageView.java we should call savePreviousImageValues(), so right now I've solved this by changing it to public and simply calling it from my Activity before I change the visibility of any of the views. But this is of course an ugly hack. I hope this helps! |
@Foosvald Thank you. I will try to repro this later. |
Thanks for your reply . Thanks & Regards On Wed, Feb 26, 2014 at 12:56 AM, Michael Ortiz notifications@github.comwrote:
|
@MikeOrtiz This does indeed fix the problem with the image becoming invisible. The problem now is that the image jumps around instead, since the saved previous values are a bit old... |
@Foosvald I could not repro your issue before. Could you paste your exact Activity and XML files (either on here or as a pastebin link), as well as your android device and os version. Thanks for your help. |
yeah i too getting the same problem @MikeOrtiz . image jumps around. |
@avi2108 @Foosvald I think I may have figured out what you guys are seeing. First, the image jumps around only when rotating the screen. Second, it only happens when the image is not zoomed in (ie getCurrentZoom == 1). Third, the scaleType must scale the image to be large than the view size (ie, CENTER_CROP or CENTER with a large image). Are these three things true? The problem is that I assume that when the image is not zoomed in, it should be centered. However, this is not true when the original, unzoomed image is larger than the view. In this case, getCurrentZoom == 1 but the user can still scroll the image. So, the image shouldn't be jumping around. Rather, on rotate (when the image is unzoomed), it should be re-centering. Is this correct? |
Hello again @MikeOrtiz Sorry for a very late answer. But this does indeed fix the exact problem I had. Thank you for a great project! We use it a lot in our (not-released-yet) app! |
When it still exists, please make a new issue or better a PR how to solve. I will merge it immediate |
Hey Mike,
I am using your Imageview class in my project all gesture working properly but when i am trying to drag other view on image view , image view getting invisible or null ?
so do you have any solution for this ?
The text was updated successfully, but these errors were encountered: