私は、すべての Android 携帯電話またはタブレット デバイスで動作する Android 2.3.3 アプリケーションを開発しています。これは、 Portraitのみをサポートします。
複数の画面をサポートする読書画面のサイズと密度がたくさんある表を見ました。
レイアウトはいくつ必要ですか? すべての画面サイズと密度に 1 つですか?
必要なのは、小、通常、大、特大の 4 つだけだと思います。
私は、すべての Android 携帯電話またはタブレット デバイスで動作する Android 2.3.3 アプリケーションを開発しています。これは、 Portraitのみをサポートします。
複数の画面をサポートする読書画面のサイズと密度がたくさんある表を見ました。
レイアウトはいくつ必要ですか? すべての画面サイズと密度に 1 つですか?
必要なのは、小、通常、大、特大の 4 つだけだと思います。
I created a tool that allows you to scale/adjust your layouts for tablets and small screen devices and made a blog post about it here: http://onemanmobile.blogspot.com/2012/04/how-to-scale-your-android-layouts-to.html
Basically, defining your layouts in dp units for one size is not enough if you want your app to fit on all devices and tablets, since there's four different "density-buckets".
This tool will allow your layouts to be converted into fitting these density buckets from a default baseline.
Hope it helps.
大きな密度までのデバイスには 1 つのレイアウトで十分です。超大画面サイズのレイアウトも実装する場合は、別のレイアウトを作成する必要があります。ldpi、mpdi、および hdpi に従って画像を取得し、それらを相対フォルダーに配置します。適切なレイアウト ウェイトを使用してレイアウトを作成する 塗りつぶしの親やボタンの正確なサイズなど、背景にフル サイズを与える
お気に入り
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bar"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".55"
android:gravity="left|center"
android:orientation="vertical" >
<Button
android:id="@+id/goBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:background="@drawable/back_btn" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".25"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forget Paaword"
android:textColor="#ffffff"
android:textSize="18dp"
android:textStyle="italic" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".55"
android:gravity="right|center"
android:orientation="vertical" >
<Button
android:id="@+id/hombutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:background="@drawable/home1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".2"
android:gravity="right|center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:gravity="right|center"
android:orientation="horizontal" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:text="User Name"
android:textColor="#ffffff" />
<EditText
android:id="@+id/usernametext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight=".5" android:imeOptions="actionDone">
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:gravity="right|center"
android:orientation="horizontal" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:text="Email Id"
android:textColor="#ffffff" />
<EditText
android:id="@+id/emailtextfp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:inputType="textEmailSubject" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/loginbuttonfp"
android:layout_width="75dp"
android:layout_height="28dp"
android:layout_margin="5dp"
android:background="@drawable/btn" android:text="Ok" android:textColor="#ffffff"/>
<Button
android:id="@+id/cancelbutton"
android:layout_width="75dp"
android:layout_height="28dp"
android:layout_margin="5dp"
android:background="@drawable/btn" android:text="Cancel" android:textColor="#ffffff"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
あなたが提供したリンクから:
By default, Android resizes your application layout to fit the current device screen.
In most cases, this works fine.
したがって、一般的なルールは、レイアウト xml のサイズ定義に密度非依存ピクセル (ディップ) を使用し、残りはオペレーティング システムによって処理されるようにすることです。そうすることで、すべての範囲のデバイスに対して唯一のレイアウトが得られます。
個別のレイアウトを作成することは、実際には一般的ではありません。引き伸ばすことができない画像がある場合にのみ、それが本当に推奨される方法です。その場合、画面のサイズと密度に基づいてグラフィックを分割すると、とにかく問題を解決できます。
基本的に4つ必要です。ただし、異なる画面サイズ と 異なる向きに応じてアプリケーションを異なる動作にさせたい場合は、次を使用する必要があります。
/layout-port > for medium layout portrait
/layout-land > for medium layout landscape
/layout-xlarge-port > for xlarge layout portrait
/layout-xlarge-land > for xlarge layout landscape
等