0

さまざまな種類のAndroidデバイスで実行できるアプリケーションのプロジェクトがあります:-small device:example samsung ace -normal device:samsung galaxi s3 -tablet 10''

私のレイアウトは複雑で、match_parentと"dp"の使用だけでは不十分です。http://developer.android.com/guide/practices/screens_support.htmlを読みましたが、すべてを理解していませんでした。

res/layout-sw720dp/main_activity.xmlたとえば、フォルダをさらに作成する必要がありますか?別の修飾子を使用する必要がありますか?それはどのくらい正確に機能しますか?

4

4 に答える 4

2

さまざまな画面サイズの場合、以下は、さまざまな画面サイズに対してさまざまなレイアウト設計を提供するアプリケーションのリソースディレクトリのリストです。

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

マニフェストの次のコードは、すべてのdpiをサポートしています。

<supports-screens android:smallScreens="true" 
          android:normalScreens="true" 
          android:largeScreens="true"
          android:xlargeScreens="true"
          android:anyDensity="true" />
于 2012-09-19T09:28:26.533 に答える
0
Kindly Use This qualifier for your Android Project with compatible screen size.

Resource          Screen Size 

layout-small       <3 inch

layout-normal      3-4 inch

layout-large       >4 inch<7.1

layout-xlarge      7.1 - 10.1 inch

それでも問題が発生する場合は、このチュートリアルリンクを使用してください

于 2012-09-19T09:30:12.283 に答える
0

異なるデバイス用に1つのアプリケーションを作成する場合は、SDKで定義されているAndroidの異なるフォルダーを使用する必要があります

例えば

drawable-ldpi - to place the images for the low screen density devices(240*320)
drawable-mdpi - to place the images for the middle screen density devices(320*480)
drawable-hdpi - to place the images for the high screen density devices(480*800)
drawable-xhdpi - to place the images for the extra high screen density devices (above 480*800)

タブレットドローブル用のアプリケーション(sw720dp)を作成して、タブレットデバイス用の画像を配置する場合(7 ")

画像を配置するために使用されるドローアブル。別のドローアブルフォルダのレイアウトを作成する必要があります

layout-ldpi - to place the layout for the low screen density devices(240*320)
layout-mdpi - to place the layout for the middle screen density devices(320*480)
layout-hdpi - to place the layout for the high screen density devices(480*800)
layout-xhdpi - to place the layout for the extra high screen density devices (above 480*800)

androidは、デバイスの密度に応じて、アプリケーションから画像とレイアウトを自動的に取得します。しかし、これには定義する必要があります

<supports-screens android:smallScreens="true" 
          android:normalScreens="true" 
          android:largeScreens="true"
          android:xlargeScreens="true"
          android:anyDensity="true" />

アプリケーションが複数の画面解像度のデバイス用に開発されるようにします。

于 2012-09-19T09:33:31.427 に答える
0

すべての密度と解像度をサポートするアプリケーションを開発するには、次の点に注意する必要があります。

(1)異なるサイズの画像(同じ名前)を4つの異なるフォルダーに次の比率で配置します。

ldpi:mdpi:hdpi:xhdpi = 3:4:6:8

(2)これらの解像度に一般的に使用されるサイズは次のとおりです。

ldpi = 36 * 36 px mdpi = 48 * 48 px hdpi = 72 * 72 px xhdpi = 96 * 96 px

ただし、画像には希望のサイズを使用することもできます(さまざまなサイズの比率にも従うようにしてください)。これらすべての画像の中から、デバイスの密度に適した画像が自動的に選択されます。

(3)これに加えて、プログラムでデバイスの密度を取得し、それに応じて次のようにレイアウトを設定することもできます。

      DisplayMetrics displayMetrics = new DisplayMetrics();
      getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
      switch(displayMetrics.densityDpi){ 
      case DisplayMetrics.DENSITY_LOW: 
        // layout for small sized devices.
        break; 
      case DisplayMetrics.DENSITY_MEDIUM: 
        // layout for medium-sized devices.
        break; 
      case DisplayMetrics.DENSITY_HIGH: 
        // layout for big-sized devices.
        break; 
      }  
于 2012-09-19T10:19:14.697 に答える