1

Considering to have this seek bar:

enter image description here.

I want to do the same thing with my image. I want to select a part of this image from 0 to 100% and track this percentage.

For example, my original image (0% selected) is all grey. If I scroll a bit with my finger on the image, I can select for example 50% of the image and change the style color to evidence this change.

enter image description here

It is important for me to track this percentage because I need this to do other things on my personal project. How is it possible to do that with android? Thanks in advance.

Francy Grillo
  • 99
  • 1
  • 10
  • `Is it possible to do that with android?` Yes, it is. – Phantômaxx Jan 08 '20 at 15:51
  • you know how? can you explain this to me, please? :) I have tried alone but without success at the moment. – Francy Grillo Jan 08 '20 at 15:54
  • The simplest way would be to have 2 overlayed images: one greyscaled and one in full color. then just cut away the portion of the colored image to show the underlying greyscale one - or the other way around. A rectangular mask would do the cutting job. Pretty much like in a photoediting software. – Phantômaxx Jan 08 '20 at 16:09
  • 1
    Thanks for the answer, I will try :) – Francy Grillo Jan 08 '20 at 17:18
  • I have a problem, I have to do this overlapping on an image that is inside a gridview. This because I have to do the same thing for different 3 images in this grid. I have found this example https://stackoverflow.com/questions/39885527/how-to-fill-images-using-progressbar-in-android, but not work in my case. – Francy Grillo Jan 08 '20 at 18:24
  • That answer looks even simpler than what I had in mind, and I find it brilliant. Try working on a simplified project, to get the grasp over the technique. Then bring it into your project. – Phantômaxx Jan 09 '20 at 10:19

1 Answers1

0

Yes, it is possible to do that with android.

You can grey out an image with the code provided in Graying out a BufferedImage and you can get the touch position with the code provided in How to get the Touch position in android? for any android app. Now, if you know where your image is in the android app, lets say its between ymin=0 and ymax=640 and you know that the finger is at y=320, you can just divide y/ymax and get the percentage (50% or 0.5) of the image that is to be shown. Now you can grey out 50% of the image, et voila.

  • Thanks for the answer, I will try :) – Francy Grillo Jan 08 '20 at 17:18
  • Glad to help. Don't forget to accept the answer if it worked for you, so other users can find it more easily. If you came up with a working code sample, you could as could as well paste it as an answer to your own question and accept it. – Georg Muehlenberg Jan 28 '20 at 13:41