Buenas tardes;
I have tried to place several images inside a ScrollView, the problem I have had is that it generates a space above and below the image; I am currently adding two images.
When I use image tag in the following way it generates the spaces above and below each image:
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/calendario1"
android:contentDescription="@string/pregrado"/>
I have apparently fixed it with the following change: android:layout_height="650dp"
<ImageView
android:layout_width="match_parent"
android:layout_height="650dp"
android:src="@drawable/calendario1"
android:contentDescription="@string/pregrado"/>
With this width and height when emulating it is showing me the images well, but with these characteristics, is the image displayed proportionally on different screens? Which is what I don't know; Also, it is showing me an Error:
Here is the complete code for this layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff"
tools:context="com.tecnologias.uniagustapp.fragmentos.Fragment_Calendario">
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:text="@string/calendario_acad_mico_i_2018"
android:textColor="#ffffff"
android:background="#130f54"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="15dp"
android:gravity="center"
android:background="#ffffff"/>
<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"
android:gravity="center">
<ImageView
android:layout_width="match_parent"
android:layout_height="650dp"
android:src="@drawable/calendario1" android:contentDescription="@string/pregrado"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="650dp"
android:src="@drawable/calendario2" android:contentDescription="@string/posgrado"/>
</LinearLayout>
</ScrollView>
Try changing the adjustViewBounds property to true on your ImageView, it works for me to adjust images to containers.
So that your images adapt to the devices, I usually leave the width in match_parent and the height in wrap_content, I have also read that to work with local images on Android it is better to use them in .png format