I am trying to move a button via Script. Here is what it looks like:
Handler handler2 = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
float y = chatButtonOne.getY();
float yB = 40;
float pxs = yB * getResources().getDisplayMetrics().density;
chatButtonOne.setY(y - pxs);
chatButtonOne2.setVisibility(View.VISIBLE);
}
}, 2000);
Now this (y - 40) is problematic in terms of different device sizes, so i am trying to use dp instead. Does anybody know how to do that?
Edit: This one here did the trick, i updated the original script i posted: