android - Programmatically set height on LayoutParams as density-independent pixels -


is there way set height/width of layoutparams density-independent pixels (dp)? looks height/width, when set programmatically, in pixels , not dp.

you need convert dip value pixels:

int height = (int) typedvalue.applydimension(typedvalue.complex_unit_dip, <height>, getresources().getdisplaymetrics()); 

for me trick.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -