How i can remove this white space at the bottom of the screen. I have also tried android:adjustviewbounds
and android:scaletype
. But still failed to remove the white space at the bottom of the screen. Please help me to optimize my layout so that i can remove that ugly white space from the bottom.
Here is the screenshot below of my layout screen.
Here is my XML code of the layout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="wrap_content"
android:layout_width="match_parent"
tools:context="com.example.zohai.v360.Fragments.Home">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="190dp"
android:layout_marginTop="-15dp">
<ImageView
android:id="@+id/intro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:background="@drawable/intro"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="190dp"
android:layout_marginTop="-15dp"
>
<ImageView
android:id="@+id/photog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/photographers"
android:adjustViewBounds="true"
android:scaleType="fitXY"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="190dp"
android:layout_marginTop="-14dp">
<ImageView
android:id="@+id/model"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/model_bg"
android:adjustViewBounds="true"
android:scaleType="fitXY"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Your layout's height is set to wrap_content
. The whitespace is there because you don't have enough size of the content to fill the screen completely. If you set the height to match_parent
you could make the whitespace go away by setting android:background
on the root view.
Otherwise you have to find out what you want there. Changing the size of the images is a bad idea because they will look stretched.
And because android is a big platform, you will see that on some devices the whitespace won't be there and on others it will be bigger. Don't set the size of the images to a fixed size.
In your xml code you have mentioned
android:layout_height="190dp"
Which usually does not help in android:scaletype
Please your constrain layout or linear layout with weight to distribute 3 linear layout to the screen height. Like this,
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="-15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="-15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="-15dp">
and then use android:scaletype
to fit the LinearLayout
Note : Different screen size matters, I think in your case the screen height is high, which cause the layout to have blank space in bottom. In small size screen it may not be like that. Try doing above will help in all screen size
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.