I have a drawable, which needs to work as the background. It needs to stretch to fill the screen (ignoring the aspect ratio).
I have provided appropriate sizes for ldpi,mdpi,hdpi and xhdpi. (I know they are appropriate by the ratio of the corresponding widths and heights, is that enough?)
I have tried to do this as follows:
using scaleType:fitXY on the imageView
This does leaves a white margin around (inside?) the imageView.
A work around that I'm not satisfied with is using centre for the scaleType like this:
I'm not satisfied because the problem still exists on tablet screens.
Note:
Update 1:
Here's the XML Layout
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" -->
<!-- xmlns:tools="http://schemas.android.com/tools" -->
<!-- android:id="@+id/FrameLayout1" -->
<!-- android:layout_width="fill_parent" -->
<!-- android:layout_height="fill_parent" -->
<!-- tools:context=".SplashScreen" > -->
<!--
This FrameLayout insets its children based on system windows using
android:fitsSystemWindows
-->
<View
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:onClick="onClickTapToContinue"
>
</View>
<ImageView
android:id="@+id/bg_gradient"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="fill"
android:adjustViewBounds="true"
android:contentDescription="@string/this_is_the_background_image"
android:scaleType="center"
android:src="@drawable/bg_gradient" />
<ImageView
android:id="@+id/bg_artwork"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/artwork_man"
android:src="@drawable/bg_artwork" />
<!-- </FrameLayout> -->
<ImageView
android:id="@+id/branding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|top"
android:adjustViewBounds="true"
android:contentDescription="@string/branding_text"
android:maxHeight="95dp"
android:paddingTop="5dp"
android:src="@drawable/title_wlcm" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:paddingBottom="5dp"
android:text="@string/tap_continue"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/white" />
</merge>
Instead of using android:src="...", use android:background="..." attribute. Hope it works.
The hack I'm going with for now is using these set of images as is for phones and maybe another set of images(and layouts?) for WVGA(Tablets).
Haven't tried this yet though. I'll post with screenshots as soon as I do.
Edit: Figures it had to do with the images themselves. There was transparent padding. Will ask designer to fix it. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With