私は、プリベースの(480x800)密度のレイアウトを作成しました。私はアンドロイド(9mths)を学び始めて以来これを使ってきました。今は他の携帯電話で自分のアプリをテストする時間でした。私は480x800の解像度を持つ3台の電話機でテストしたところ、320x480と240x320の解像度でテストするまでは問題ありませんでした。私はpx-sを幅と高さ、paddingTopなどどこでも使用しました。 エミュレータでアプリケーションをチェックしましたが(異なる解像度のavd-sを作成しました)、レイアウト全体を見ることができません。画面より大きかったので(Eclipseでのみテストしています)それは "wrap_content"幅と高さの設定で4つの画像を持っています。 したがって、アンドロイドのドキュメントを確認しました。他のレイアウトやその他のものは作成していませんが、px-sをdp-sに置き換えました。同じです。 私は190x60pxの解像度で小さなボタン(下図参照)を作成し、ldpiフォルダに入れましたが、大きな進歩はありませんでした。おそらく、テキストビューのテキストサイズが同じで、240x320解像度の場合は2つのテキストビューがディスプレイの1/3になります(480x800の場合は1/6)。 (テキストは大きな解像度に比べて小さい解像度で大きく見えます) 480x800のようなこの320x480解像度でレイアウトを見せるためにはどうすればいいですか教えてください。アンドロイド密度に依存しない
gradientbgのサイズ:これはシェイプの.xmlファイルなので物理サイズはありません。ボタンの サイズ(画像):380x150px hdpi(またはLDPIフォルダ内190x60px)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/gradientbg"
>
<TextView
android:id="@+id/TextView00"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#E30000"
android:textColor="#FFFFFF"
android:gravity="center_horizontal|center_vertical"
android:textSize="26dp"
android:height="40dp"
android:textStyle="bold"
android:text="Main menu"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="App"
android:textSize="30dp"
android:textStyle="bold"
android:paddingTop="20dp"
android:layout_gravity="center_horizontal"
android:textColor="#FFB300"
/>
<Button android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/mainbutton_1"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dip"
/>
<Button android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/mainbutton_2"
android:layout_gravity="center_horizontal"
android:paddingTop="5dp"
/>
<Button android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/mainbutton_3"
android:layout_gravity="center_horizontal"
android:paddingTop="5dp"
/>
<Button android:id="@+id/btn4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/mainbutton_4"
android:layout_gravity="center_horizontal"
android:paddingTop="5dp"
/>
</LinearLayout>
さまざまなサイズのレイアウトを作成します。あなたはこの質問を見ることができます:http://stackoverflow.com/questions/5726764/android-layouts-for-multiple-screen-sizes –
ピクセル密度と画面サイズは全く異なるものです。リソースをldpiフォルダに置くと、それらは小さな画面では必ずしも使用されません。そのためには、それらを小さなフォルダに入れる必要があります。詳細は、[複数の画面のサポート](http://developer.android.com/guide/practices/screens_support.html)を参照してください。 –
どちらが良い方法ですか?さまざまなサイズのボタン(イメージ)を作成するか、幅と高さを比例(たとえば、hdpiの場合は380dp、ldpiの場合は190dp)サイズに設定するのに十分です(右)。最後の方が簡単で効果的ですが、私は好奇心が強いです。 – erdomester