Back to project page nxt-remote-controller.
The source code is released under:
MIT License
If you think the Android project nxt-remote-controller listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.gc.materialdesign.utils; /*from w w w. j a v a 2 s . c om*/ import android.content.res.Resources; import android.util.TypedValue; import android.view.View; public class Utils { /** * Convert Dp to Pixel * ?dp?????pixel */ public static int dpToPx(float dp, Resources resources){ float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics()); return (int) px; } /** * @param value * @return ?dip??dp??float */ public static float dipOrDpToFloat(String value) { if (value.indexOf("dp") != -1) { value = value.replace("dp", ""); } else { value = value.replace("dip", ""); } return Float.parseFloat(value); } public static int getRelativeTop(View myView) { // if (myView.getParent() == myView.getRootView()) if(myView.getId() == android.R.id.content) return myView.getTop(); else return myView.getTop() + getRelativeTop((View) myView.getParent()); } public static int getRelativeLeft(View myView) { // if (myView.getParent() == myView.getRootView()) if(myView.getId() == android.R.id.content) return myView.getLeft(); else return myView.getLeft() + getRelativeLeft((View) myView.getParent()); } }