FrameLayout layout = (FrameLayout) findViewById(R.id.layout);
ViewGroup.LayoutParams lp =layout.getLayoutParams();
DisplayMetrics displayMetrics = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
String px = displayMetrics.widthPixels + " x " + displayMetrics.heightPixels;
String dp = displayMetrics.xdpi + " x " + displayMetrics.ydpi;
String density = "densityDpi = " + displayMetrics.densityDpi + ", density=" + displayMetrics.density + ", scaledDensity = " + displayMetrics.scaledDensity;
Log.e("test", "px = " + px + ", dp = " + dp + ",density " + density);
Log.e("test", "framelayout height = " + lp.height);
Log.e("test", "framelayout width = " + lp.width);
lp.height = displayMetrics.widthPixels/3;
參考網址:
http://saminjava.blogspot.tw/2013/09/android.html
http://ikevin.tw/?cat=9
沒有留言:
張貼留言