アプリでさまざまな画面サイズをサポートしたい。/res ディレクトリに「layout-small および layout-large」フォルダを追加します。しかし、このフォルダー内の XML はアクティビティでアクセスできません。そのため、すべての XML をデフォルトのレイアウトに追加し、このコードを追加します。
if((getResources().getConfiguration().screenLayout &&
Configuration.SCREENLAYOUT_SIZE_SMALL) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
setContentView(R.layout.main1);
}else if((getResources().getConfiguration().screenLayout &&
Configuration.SCREENLAYOUT_SIZE_LARGE) == Configuration.SCREENLAYOUT_SIZE_LARGE){
setContentView(R.layout.main2);
}
else
setContentView(R.layout.main);
私のアクティビティでは、AVD スキンが 1024*600 で hw.lcd.dencity が 160 (大) の場合、機能しませんでした。
助けはありますか?