DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int widthPixels = metrics.widthPixels; int heightPixels = metrics.heightPixels; float scaleFactor = metrics.density; float widthDp = widthPixels / scaleFactor; float heightDp = heightPixels / scaleFactor; float smallestWidth = Math.min(widthDp, heightDp); if (smallestWidth > 720) { //Device is a 10" tablet adView.setAdSize(new AdSize(770, 80)); } else if (smallestWidth > 600) { //Device is a 7" tablet adView.setAdSize(new AdSize(570, 80)); }
Jun 22, 2017
Android: Device is a 10" tablet or 7" tablet
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment