0

アプリで複数の Android 画面をサポートしている問題についてアドバイスを求めています。

複数の画面のサポートに関する記事を読みました。アドバイスに従い、4 つの /res レイアウト フォルダー /layout-small、/layout-normal、/layout-large、/layout-xlarge を作成しました。私は主に RelativeLayouts を使用し、すべての単位はディップで測定されます。

私のさまざまなテストデバイスでは、これはすべて正常に機能します。ただし、多くのユーザーから、データが画面の端からはみ出しているという連絡がありました。優れたScreen info アプリを使用して詳しく調べると、アプリをテストできたデバイスには、Normal HDPI、Normal XHDPI、および XLarge MDPI 画面がありますが、問題のあるユーザー デバイスには Large MDPI 画面があることがわかります。

私の IDE は IntelliJ Idea で、これにはプレビュー モードがあり、さまざまな画面エミュレーションに対してレイアウトをテストできます。大画面をエミュレートするために、プレビュー モードを 7 インチ WSVGA (タブレット) に設定しました。それは正しいと思いますか?私は実際の大画面テスト デバイスを所有していません。

特定のデバイスで問題が発生する理由がわかりません。既にデザインした 4 つのレイアウト以外は作成する必要がないのでしょうか? 4でも、画面を追加するたびに、それぞれの値を更新する必要があるのは本当に面倒です。

他の開発者は、さまざまなテスト デバイスを用意せずに、さまざまな画面サイズ/密度をどのようにテストしていますか?

編集 私が言ったはずです-私の画面はボタンとテキストビューのみで構成されており、話すグラフィックはありません。

EDIT 2 スクリーンショットを追加しました。1 つ目 (実際には写真) は、ユーザー デバイスに表示される画面レイアウトを示しています (金曜日は表示されないことに注意してください)。2 番目は、プログラムが正常に動作していることを示しています。

編集 3 レイアウトに使用される XML コードの一部を含めました

時刻表の表示が正しくない 正しい時刻表ビュー

<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
             android:background="@drawable/paper_thin_background"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:paddingLeft="15dip"
             android:paddingTop="15dip"
    >

<TextView
        android:id="@+id/timetable_week"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="25dip"
        android:textSize="20sp"
        android:textColor="#15252D"
        android:text="@string/timetable_week"
        android:paddingTop="10dip"
        android:paddingBottom="30dip"
        />

<Spinner
        android:id="@+id/timetable_week_spinner"
        android:layout_toRightOf="@id/timetable_week"
        android:layout_height="wrap_content"
        android:prompt="@string/enterday"
        android:layout_width="140dip"
        android:entries="@array/timetable_weeks"
        android:textSize="205sp"
        android:textColor="#768766"
        />
            <TextView
                android:id="@+id/period_heading"
                android:layout_width="120dp"
                android:layout_height="wrap_content"
                android:textColor="#768766"
                android:text="@string/period"
                android:textSize="20sp"
                android:paddingBottom="15dip"
                android:gravity="center_horizontal"
                android:layout_below="@+id/timetable_week"
            />

            <TextView
                    android:id="@+id/monday_heading"
                    android:layout_toRightOf="@id/period_heading"
                    android:layout_width="170dp"
                    android:layout_height="wrap_content"
                    android:textColor="#768766"
                    android:text="@string/monday"
                    android:textSize="20sp"
                    android:paddingBottom="15dip"
                    android:gravity="center_horizontal"
                    android:layout_below="@+id/timetable_week"
                    />

            <TextView
                    android:id="@+id/tuesday_heading"
                    android:layout_toRightOf="@id/monday_heading"
                    android:layout_width="170dp"
                    android:layout_height="wrap_content"
                    android:textColor="#768766"
                    android:text="@string/tuesday"
                    android:textSize="20sp"
                    android:paddingBottom="15dip"
                    android:gravity="center_horizontal"
                    android:layout_below="@+id/timetable_week"
                    />
            <TextView
                    android:id="@+id/wednesday_heading"
                    android:layout_toRightOf="@id/tuesday_heading"
                    android:layout_width="170dp"
                    android:layout_height="wrap_content"
                    android:textColor="#768766"
                    android:text="@string/wednesday"
                    android:textSize="20sp"
                    android:paddingBottom="15dip"
                    android:gravity="center_horizontal"
                    android:layout_below="@+id/timetable_week"
                    />
            <TextView
                    android:id="@+id/thursday_heading"
                    android:layout_toRightOf="@id/wednesday_heading"
                    android:layout_width="170dp"
                    android:layout_height="wrap_content"
                    android:textColor="#768766"
                    android:text="@string/thursday"
                    android:textSize="20sp"
                    android:paddingBottom="15dip"
                    android:gravity="center_horizontal"
                    android:layout_below="@+id/timetable_week"
                    />
            <TextView
                    android:id="@+id/friday_heading"
                    android:layout_toRightOf="@id/thursday_heading"
                    android:layout_width="170dp"
                    android:layout_height="wrap_content"
                    android:textColor="#768766"
                    android:text="@string/friday"
                    android:textSize="20sp"
                    android:paddingBottom="15dip"
                    android:gravity="center_horizontal"
                    android:layout_below="@+id/timetable_week"
                    />

    <!-- PERIOD 1-->

            <TextView
                    android:id="@+id/p1_heading"
                    android:layout_below="@id/period_heading"
                    android:layout_width="120dp"
                    android:layout_height="wrap_content"
                    android:textColor="#768766"
                    android:text="@string/p1"
                    android:textSize="20sp"
                    android:paddingBottom="15dip"
                    android:gravity="center_horizontal"
                    />

            <TextView
                    android:id="@+id/monp1"
                    android:layout_below="@id/period_heading"
                    android:layout_toRightOf="@id/period_heading"
                    android:layout_width="170dp"
                    android:layout_height="wrap_content"
                    android:textColor="#15252D"
                    android:text="@string/blank"
                    android:textSize="20sp"
                    android:paddingBottom="15dip"
                    android:gravity="center_horizontal"
                    />

            <TextView
                    android:id="@+id/tuep1"
                    android:layout_below="@id/period_heading"
                    android:layout_toRightOf="@id/monp1"
                    android:layout_width="170dp"
                    android:layout_height="wrap_content"
                    android:textColor="#15252D"
                    android:text="@string/blank"
                    android:textSize="20sp"
                    android:paddingBottom="15dip"
                    android:gravity="center_horizontal"
                    />

            <TextView
                    android:id="@+id/wedp1"
                    android:layout_below="@id/period_heading"
                    android:layout_toRightOf="@id/tuep1"
                    android:layout_width="170dp"
                    android:layout_height="wrap_content"
                    android:textColor="#15252D"
                    android:text="@string/blank"
                    android:textSize="20sp"
                    android:paddingBottom="15dip"
                    android:gravity="center_horizontal"
                    />

            <TextView
                    android:id="@+id/thup1"
                    android:layout_below="@id/period_heading"
                    android:layout_toRightOf="@id/wedp1"
                    android:layout_width="170dp"
                    android:layout_height="wrap_content"
                    android:textColor="#15252D"
                    android:text="@string/blank"
                    android:textSize="20sp"
                    android:paddingBottom="15dip"
                    android:gravity="center_horizontal"
                    />

            <TextView
                    android:id="@+id/frip1"
                    android:layout_below="@id/period_heading"
                    android:layout_toRightOf="@id/thup1"
                    android:layout_width="170dp"
                    android:layout_height="wrap_content"
                    android:textColor="#15252D"
                    android:text="@string/blank"
                    android:textSize="20sp"
                    android:paddingBottom="15dip"
                    android:gravity="center_horizontal"
                    />
4

2 に答える 2

2

アプリを構造化するための非常に優れた方法ではありません。ランダムで静的なレイアウト(つまり、テーブル、グリッド、またはリストとして分類されていない)がある場合は、個々のビューを自由に使用できますが、動的で分類されたレイアウトがある場合は、多くのビューを使用することはお勧めできません。管理が難しい。

たとえば。あなたの場合、データのテーブルまたはグリッドを表示する必要がありました。多くのテキストビューを使用してこれを実装しました。現在、一部のデバイスでは適合し、一部のデバイスでは適合しません。グリッドビューのような動的ビューを使用すると、小さなコードで簡単に実現できます。
グリッドビューを使用する場合は、アイテムとしてグリッドビューとテキストビューが必要です。これで、デバイスのサイズに応じて、列の幅(テキストアイテムのサイズ)を変更でき、レイアウトはどのデバイスにも簡単に収まります。

複数のデバイスをサポートする必要がある場合は、xml(異なるフォルダー内の異なるxml)とコードの組み合わせを使用する必要があります。

GridViewチュートリアルへの非常に良いリンク。

于 2012-09-20T19:57:15.607 に答える
0

私が経験している問題は、DIP 測定と組み合わせた相対レイアウトの使用に関連していることに気付きました。この方法で膨大な範囲のデバイスをサポートすることは不可能です。

代わりに、android:weightSum と android:layout_weight を使用して、アプリのすべての画面を再設計しました。

これにより、理論的には、さまざまな画面サイズに対するアプリの適応性が大幅に向上するはずです。

于 2012-09-30T18:56:40.400 に答える