1. 程式人生 > >android 中在程式碼中設定dp單位的元件高度

android 中在程式碼中設定dp單位的元件高度

原文地址:http://write.blog.csdn.net/postedit

DisplayMetrics metrics = new DisplayMetrics() getWindowManager().getDefaultDisplay().getMetrics(metrics); int heighDP = Utils. getDPI(height, metrics); ViewGroup.LayoutParams params = locationListView.getLayoutParams(); params. height = heighDP; locationListView
.setLayoutParams(params);