ドローアブル用にさまざまなフォルダーがあるのと同じように、画面サイズ用にさまざまなレイアウトを作成できます。
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
Android ドキュメントから: http://developer.android.com/guide/practices/screens_support.html
編集:
デバイスがハンドセットかタブレットかをプログラムで検出するには、次のコードを使用できます。
public static boolean isTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK)
>= Configuration.SCREENLAYOUT_SIZE_LARGE;
}
次に、アクティビティで、前の値に応じて異なるレイアウトを設定できます。
@Override
onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
if isTablet(this)
setContentView(R.layout.handset_main_layout);
else
setContentView(R.layout.tablet_maint_layout);
}
これはほんの一例です。