Reputation: 23371
I am trying to get this layout to take up the entire screen on my Samsung Galaxy Tab 10.1, which has a screen size of roughly 800x1280.
i have the following xml in my res/layout-hdpi and res/layout, and my @drawable/background is in both res/drawable and res/drawable-hdpi where the background image in hdpi is 800x1280 size.
However, when i render the following, i can't get it to ever take up the entire screen. I've tried to get rid of ScrollView, change relativelayout to be linearlayout and set their layout_height="match_parent" but nothing changes... i've tried to clean project, uninstall app from the device before re-loading it... nothing seems to be working. Will someone please explain what's happening? I think i'm missing something really important.
(note: this works fine on my kindle fire and 7" tablets where the screen size is 600x1024 ish)
<?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>
Upvotes: 1
Views: 1624
Reputation: 11141
You should use either fill_parent
or match_parent
instead of wrap_content
as, wrap_content takes only as much height as is needed by the content, but fill_parent or match_parent takes on the entire height.
Upvotes: 1
Reputation: 6250
Well, there are some things that you should take care of first, which are probably the reasons why other things to not to be processed in the right way. A relativeLayout doesn't have/need any "orientation" parameter, you should remove it. Moreover I'd recommend to use either fill_parent or match_parent and not both together. (note that match_parent achieves the same result but it is only available from API 8 onwards).
Ultimately, make sure your image has the amount of pixel you point there: mind the resolution of the image (ppi)
Upvotes: 0