5

簡単なクイズテストアプリ「Target SDK API 16 (4.1 Jelly Beans)」画面 3.7 (480x800 hdpi) を作成しています。

このアプリは 3.7 (480x800) では見栄えがしますが、2.7 (240x320)、7.0 (1024x600)、10.1 (1280x800) などの別のスクリーニング デバイスで実行すると、画面の解像度が乱れたり、見栄えが悪くなります。

理解を深めるために、スクリーンショットを参照してください。

2.7 (240x320)

http://postimg.cc/image/m3sob88mp/

3.7 (480x800)

http://postimg.cc/image/wf513w0c1/

7.0 (1024x600)

http://postimg.cc/image/fc298djn5/

10.1 (1280x800)

http://postimg.cc/image/isk5gon7p/

3.7 (480x800) のように、すべての画面サイズと互換性があり、完璧に見えるようにしたい

自動サイズ変更、互換性を持たせ、すべての Android デバイスの画面サイズを調整して、すべての画面解像度で完璧に見えるようにする方法は?

それとも、別のアプリや別の画面サイズを作成する必要がありますか?

画面の互換性を確保しようとしたのは、次の行を「AndroidManifest.xml」に追加したことです

<supports-screens>

        android:resizeable="true"
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true"
        android:anyDensity="true"

    </supports-screens>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.usd.quiztest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name="com.usd.quiztest.Logo"
            android:label="@string/app_name"            
            android:theme="@android:style/Theme.Black.NoTitleBar" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />               
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>

        <activity
            android:name="com.usd.quiztest.First"
            android:label="@string/app_name" >
        </activity>                
        <activity
            android:name="com.usd.quiztest.Q1"
            android:label="@string/app_name" >
        </activity>        
         <activity
            android:name="com.usd.quiztest.Q2"
            android:label="@string/app_name" >
        </activity>
         <activity
            android:name="com.usd.quiztest.Q3"
            android:label="@string/app_name" >
        </activity>
         <activity
            android:name="com.usd.quiztest.Q4"
            android:label="@string/app_name" >
        </activity>
         <activity
            android:name="com.usd.quiztest.Q5"
            android:label="@string/app_name" >
        </activity>
         <activity
            android:name="com.usd.quiztest.FinalPage"
            android:label="@string/app_name" >
        </activity>
         <activity
            android:name="com.usd.quiztest.Score"
            android:label="@string/app_name" >
        </activity>

    </application>

</manifest>

first_screen.xml (これは、スクリーンショットに表示されている画面です)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"    
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp"
        android:contentDescription="ql"
        android:gravity="center"
        android:src="@drawable/ql" />

    <Button
        android:id="@+id/start_button"
        android:layout_width="254dp"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp"
        android:text="Start Quiz Test"
        android:textColor="#000000" />

</RelativeLayout>
4

3 に答える 3

9

さまざまな画面サイズをサポートしたい場合、重要なことがいくつかあります。

  • 画面密度バケットごとに異なるドローアブルを使用する ( drawables-hdpidrawables-xhdpiなど)
  • サイズの単位としてdpの代わりに使用します。px
  • 絶対サイズの使用を避け、余白を使用して、それに応じて Android にスケーリングさせます。

複数の画面サイズのサポートについて詳しくは、こちらをご覧ください。

編集:

異なるボタン/フォント サイズと余白を使用するには、dimens.xml.

res/values-hdpi/dimens.xml
res/values-xhdpi/dimens.xml

dimens.xml

<resources>
    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>
</resources>
于 2014-05-12T10:37:14.850 に答える
2

リニア レイアウトをメイン レイアウトとして使用し、weightSum を使用して分割し、他のサブ リニア レイアウトを使用して、メイン レイアウト全体から各サブ リニア レイアウトに weightSum を割り当てます。サブレイアウトで UI ウィジェットを管理します。これが以下の例です

于 2016-08-03T07:32:40.540 に答える