I understand the difference between the various measurement units used in android layouts (dp, sp, px, etc), but it’s not clear to me which unit is used when setting the width via java code.
Which unit does setMinimumWidth(int minWidth) use?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Pixels. All values set by code are in pixels. If you want different values, you must compute pixels using getResources().getDisplayMetrics().density to do conversion (or using other values from DisplayMetrics).