Skip to content

Instantly share code, notes, and snippets.

@devrath
Last active November 25, 2015 14:37
Show Gist options
  • Select an option

  • Save devrath/4f9b254c345be0b93c2b to your computer and use it in GitHub Desktop.

Select an option

Save devrath/4f9b254c345be0b93c2b to your computer and use it in GitHub Desktop.
Dynamic plotPoints send to server and RePlot it
//Use this code to get Device's height and width and save them to variable, like this
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int height = displaymetrics.heightPixels;
int width = displaymetrics.widthPixels;
//After getting your X and Y use below mentioned function to get percentage
int percentageX= (int)((x*100)/width)
int percentageY= (int)((y*100)/height)
//Save these as coordinates in server
//Now before you reuse the plot points from server. Convert them back to Pixels using
int newX = (int)((x*width)/100)
int newy = (int)((y*height)/100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment