Esempio n. 1
0
 /**
  * 将dp转换成px
  *
  * @param dp
  * @return
  */
 public static float dpToPx(float dp)
 {
     return(dp * AppUtils.getAppContext().Resources.DisplayMetrics.Density);
 }
Esempio n. 2
0
 /**
  * 获取屏幕高度
  *
  * @return
  */
 public static int getScreenHeight()
 {
     return(AppUtils.getAppContext().Resources.DisplayMetrics.HeightPixels);
 }
Esempio n. 3
0
 /**
  * 获取屏幕宽度
  *
  * @return
  */
 public static int getScreenWidth()
 {
     return(AppUtils.getAppContext().Resources.DisplayMetrics.WidthPixels);
 }
Esempio n. 4
0
 /**
  * 将sp值转换为px值
  *
  * @param spValue
  * @return
  */
 public static float spToPx(float spValue)
 {
     return(spValue * AppUtils.getAppContext().Resources.DisplayMetrics.ScaledDensity);
 }
Esempio n. 5
0
 /**
  * 将px值转换为sp值
  *
  * @param pxValue
  * @return
  */
 public static float pxToSp(float pxValue)
 {
     return(pxValue / AppUtils.getAppContext().Resources.DisplayMetrics.ScaledDensity);
 }
Esempio n. 6
0
 /**
  * 将px转换成dp
  *
  * @param px
  * @return
  */
 public static float pxToDp(float px)
 {
     return(px / AppUtils.getAppContext().Resources.DisplayMetrics.Density);
 }