2011-12-06 5 views
0

アンドロイドインターフェイスを設計するとき、私の初期キャンバスはどのサイズですか?私はあらゆる種類の画面に対応したレイアウトを作りたいと思っています - 特定の大きなデザインから始め、そこから縮小することは可能ですか?すなわち、960x720?アンドロイドインターフェイスを設計するとき、私の初期キャンバスはどのサイズですか?

Display display = getWindowManager().getDefaultDisplay(); 
    int width = display.getWidth(); 
    int height = display.getHeight(); 

と方向:あなたは、画面サイズを取得しようとすることができ

答えて

2

public int getScreenOrientation() { 
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { 
     return 1; // Portrait Mode 
    }else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { 
     return 2; // Landscape mode 
    } 
    return 0; 
} 
0

はあなたのレイアウトで各画素の修正量を避けるようにしてください。 パーたとえば、このコードは、画面のように幅が二つのボタン、各半分を描画します:

<LinearLayout 
    android:id="@+id/Tab1_Buttonline1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 
    <Button 
     android:id="@+id/function_datasync" 
     android:layout_width="wrap_content" 
     android:text="Daten Sync" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:layout_margin="5dip" 
     android:textAppearance="?android:attr/textAppearanceLargeInverse" 
     android:maxLines="1"> 
    </Button> 
    <Button 
     android:id="@+id/function_docsync" 
     android:layout_width="wrap_content" 
     android:text="Datei Sync" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:layout_margin="5dip" 
     android:textAppearance="?android:attr/textAppearanceLargeInverse" 
     android:maxLines="1"> 
    </Button> 
</LinearLayout> 

ます。また、描画可能-hdpi/-mdpiまたは-ldpi fodersをusinによって異なる解像度のための異なるレイアウトを定義できます、異なるドロウアブルを定義することができます。

最後に、コントロールの特定の高さや重さを設定しなければならない場合などに使用します。

android:layout_margin="5dip" 

"ディップ"のため、すべての解像度で同じように余白が表示されます。

関連する問題