Search code examples
androidandroid-imageviewandroid-framelayout

Image is not fitting on whole screen for tablet


I want to set the background to LinearLayout , I took reference from this. But still it lefts spaces to 4 sides. screen shot is screenshot

Code is the following

   <FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@mipmap/background"
        android:scaleType="fitXY" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">
<someviews></someviews>
 </LinearLayout>
</FrameLayout>

Please give some solution if any.


Solution

    • Use android:src instead of android:background.
    • Add android:adjustViewBounds="true"

    Sets a drawable as the content of this ImageView.

    Finally

    <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@mipmap/background"
            android:scaleType="fitXY"
            android:adjustViewBounds="true" />