获取当前屏幕的密度系数 ,并设置控件以dp为单位的长宽
float density = getResources().getDisplayMetrics().density;
params = new LayoutParams((int) (10 * density), (int) (10 * density));
params.setMargins((int) (10 * density), 0, (int) (10 * density), 0);
时间: 2024-11-19 21:10:18