public static float px2dp(Context context, float pxVal) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (pxVal / scale);
    }
public static float px2dp ( Context context , float pxVal ) { final float scale = context . getResources ( ) . getDisplayMetrics ( ) . density ; return ( pxVal / scale ) ; }
px转dp

@param context
@param pxVal
@return