Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android布局-为什么RelativeLayout不占据平板电脑的整个屏幕?_Android_Android Layout_Screen_Android Relativelayout - Fatal编程技术网

Android布局-为什么RelativeLayout不占据平板电脑的整个屏幕?

Android布局-为什么RelativeLayout不占据平板电脑的整个屏幕?,android,android-layout,screen,android-relativelayout,Android,Android Layout,Screen,Android Relativelayout,我正试图让这个布局占据我的三星Galaxy Tab 10.1的整个屏幕,它的屏幕大小大约为800x1280 在我的res/layout hdpi和res/layout中有以下xml,我的@drawable/background同时在res/drawable和res/drawable hdpi中,其中hdpi中的背景图像大小为800x1280 然而,当我渲染以下内容时,我无法让它占据整个屏幕。我试图摆脱ScrollView,将relativelayout更改为linearlayout,并设置它们的

我正试图让这个布局占据我的三星Galaxy Tab 10.1的整个屏幕,它的屏幕大小大约为800x1280

在我的res/layout hdpi和res/layout中有以下xml,我的@drawable/background同时在res/drawable和res/drawable hdpi中,其中hdpi中的背景图像大小为800x1280

然而,当我渲染以下内容时,我无法让它占据整个屏幕。我试图摆脱ScrollView,将relativelayout更改为linearlayout,并设置它们的布局\u height=“match\u parent”,但没有任何改变。。。我已尝试清理项目,在重新加载之前从设备卸载应用程序。。。似乎什么都没用。有人能解释一下发生了什么事吗?我想我错过了一些非常重要的事情

(注意:这在我的kindle fire和7英寸平板电脑上运行良好,屏幕尺寸为600x1024英寸)


嗯,有些事情你应该首先处理,这可能就是为什么其他事情不能以正确的方式处理的原因。 relativeLayout没有/不需要任何“方向”参数,您应该删除它。 此外,我建议使用fill_parent或match_parent,而不要同时使用两者(注意match_parent可以获得相同的结果,但它只能从API 8开始使用)


最后,确保你的图像有你指向那里的像素量:注意图像的分辨率(ppi)

你应该使用
fill\u parent
match\u parent
而不是
wrap\u content
as,wrap\u content只占据内容所需的高度,但fill\u parent或match\u parent占据整个高度。

是的,我没有完全理解,我完全忘记了它是作为wrap content的(当我使用10英寸平板电脑时,它没有占据整个屏幕)。谢谢!
<?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>