あなたが動的に設定することができますこのような各アクティビティの内部:
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