0

画面サイズが約 800x1280 の Samsung Galaxy Tab 10.1 で、このレイアウトを画面全体に表示しようとしています。

res/layout-hdpi と res/layout に次の xml があり、@drawable/background は res/drawable と res/drawable-hdpi の両方にあり、hdpi の背景画像は 800x1280 サイズです。

ただし、次をレンダリングすると、画面全体を占有することはできません。ScrollView を取り除き、relativelayout を linearlayout に変更し、layout_height="match_parent" を設定しようとしましたが、何も変わりません... プロジェクトをクリーンアップし、再ロードする前にデバイスからアプリをアンインストールしようとしました...何も機能していないようです。誰かが何が起こっているのか説明してくれますか? 私は本当に重要な何かを見逃していると思います。

(注: これは私の kindle fire と、画面サイズが 600x1024 っぽい 7 インチのタブレットで問題なく動作します)

<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <RelativeLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@drawable/background">

        <RelativeLayout 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/game_relativelayout_top_textview_definition_and_example"
            >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/game_screen_image_box"
                android:id="@+id/game_linearlayout_top_textview_definition_and_example"
                android:orientation="vertical"
                >
                <TextView
                    android:id="@+id/game_textview_definition"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/padding_double"
                    android:layout_marginLeft="@dimen/padding_quadruple"
                    android:layout_marginRight="@dimen/padding_quadruple"
                    android:gravity="center_horizontal"
                    android:textSize="@dimen/font_size_slight_larger"
                    android:textColor="@android:color/black"
                    android:text="@string/filler" />

                <ImageView 
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/padding_double"
                    android:src="@drawable/details_page_screen_divider"
                    android:contentDescription="@string/filler" />

                <TextView
                    android:id="@+id/game_textview_example"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/padding_double"
                    android:layout_marginLeft="@dimen/padding_quadruple"
                    android:layout_marginRight="@dimen/padding_quadruple"
                    android:gravity="center_horizontal"
                    android:textSize="@dimen/font_size_slight_larger"
                    android:textStyle="italic"
                    android:textColor="@android:color/black"
                    android:text="@string/filler" />
            </LinearLayout>         

            <ImageView
                android:id="@+id/game_imageview_thumbs_down"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentBottom="true"
                android:layout_marginRight="@dimen/padding_quadruple"
                android:layout_marginBottom="@dimen/padding_quadruple"
                android:src="@drawable/game_screen_image_thumbs_down"
                android:contentDescription="@string/filler"
                />
            <ImageView
                android:id="@+id/game_imageview_thumbs_up"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@id/game_imageview_thumbs_down"
                android:layout_alignParentBottom="true"
                android:layout_marginRight="@dimen/padding_double"
                android:layout_marginBottom="@dimen/padding_quadruple"
                android:src="@drawable/game_screen_image_thumbs_up"
                android:contentDescription="@string/filler"
                />  
        </RelativeLayout>

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/game_imageview_timer_foreground"
            android:src="@drawable/game_screen_image_timer_foreground"
            android:contentDescription="@string/filler"
            android:layout_below="@id/game_relativelayout_top_textview_definition_and_example"
            />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/game_imageview_timer_background"
            android:src="@drawable/game_screen_image_timer_background"
            android:contentDescription="@string/filler"
            android:layout_below="@id/game_relativelayout_top_textview_definition_and_example"
            />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_below="@id/game_imageview_timer_foreground"
            android:layout_marginTop="@dimen/padding_single">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
                <Button
                    android:id="@+id/game_button_answer_choice_1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:textSize="@dimen/font_size_regular"
                    android:text="@string/filler"
                    android:background="@drawable/game_screen_button_top_left"/>
                <Button
                    android:id="@+id/game_button_answer_choice_2"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:textSize="@dimen/font_size_regular"
                    android:text="@string/filler"
                    android:background="@drawable/game_screen_button_top_right"/>
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
                <Button
                    android:id="@+id/game_button_answer_choice_3"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:textSize="@dimen/font_size_regular"
                    android:text="@string/filler"
                    android:background="@drawable/game_screen_button_bottom_left"/>
                <Button
                    android:id="@+id/game_button_answer_choice_4"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:textSize="@dimen/font_size_regular"
                    android:text="@string/filler"
                    android:background="@drawable/game_screen_button_bottom_right"/>
            </LinearLayout>
        </LinearLayout>

    </RelativeLayout>
</ScrollView>
4

2 に答える 2

1

asの代わりにfill_parentorを使用する必要があります。match_parentwrap_content

于 2012-09-05T05:25:52.140 に答える
0

そうですね、最初に気をつけなければならないことがいくつかありますが、それがおそらく、他のことが正しく処理されない理由です。relativeLayout には「方向」パラメーターがありません/必要ありません。削除する必要があります。さらに、両方を一緒に使用するのではなく、fill_parent または match_parent のいずれかを使用することをお勧めします。(match_parent は同じ結果を達成しますが、API 8 以降でのみ使用できることに注意してください)。

最終的には、画像に指定したピクセル数があることを確認してください。画像の解像度 (ppi) に注意してください。

于 2012-09-04T20:51:02.113 に答える