당신은 동적으로 설정할 수 있습니다 다음과 같은 각 활동 내부 :
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
// ...
// Call setTheme before creation of any(!) View.
if(isTablet()) {
setTheme(android.R.style.Black);
}
else {
setTheme(android.R.style.Theme_Dark);
}
// ...
setContentView(R.layout.main);
}
이제 isTablet
메서드가 필요하지만 장치 유형을 감지하는 것은 약간 어렵습니다. 여기에 온라인으로 볼 수있는 방법은, 그것은 화면 크기를 확인하고 화면이 큰 경우는 현재 장치가 태블릿 : 아이디어에 대한
public boolean isTablet() {
try {
// Compute screen size
DisplayMetrics dm = context.getResources().getDisplayMetrics();
float screenWidth = dm.widthPixels/dm.xdpi;
float screenHeight = dm.heightPixels/dm.ydpi;
double size = Math.sqrt(Math.pow(screenWidth, 2) +
Math.pow(screenHeight, 2));
// Tablet devices should have a screen size greater than 6 inches
return size >= 6;
} catch(Throwable t) {
Log.error(TAG_LOG, "Failed to compute screen size", t);
return false;
}
}
고마워, 그 perfekt 일했습니다! – Georg