You want to express your layouts in terms of device-independent pixels ("dip"), yes. That is not the same as pixels. But yes that's exactly what you need to do, to convert from the dip dimension to pixels, and then generate a barcode of that size in pixels. The library of course has no notion of "dip", only "px".
Call getResources().getDisplayMetrics()
in your app. The density
field on DisplayMetrics is the conversion factor you need. Just multiply dip by this value and round to get the right size in px.