Reputation: 101
developers out there,
I want to make a GridLayout, which contains several imageViews, but the size of each cell of the GridLayout isn't set yet, because the GridLayoutchanges its size depending on the screen size (ConstraintLayout).
Now I've got the problem that when the Image is bigger than the cell, it is shown on the device (in the android studio it is shown).
I already tried things like setting the image as background, background-tint or change android:background="@drawable/inventarslot"
to app:background="@drawable/inventarslot"
which was said in other posts in this forum.
This is my GridLayout:
<android.support.v7.widget.GridLayout
android:id="@+id/gl_equipeditems"
android:layout_width="0dp"
android:layout_height="75dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView8">
This is my ImageView:
<ImageView
android:id="@+id/iv_slot1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profil"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="0"
app:layout_rowWeight="1"/>
Thank you for your help
Greetings Pumpanickel
Upvotes: 0
Views: 973
Reputation: 11497
Since you're displaying the images based on the screen size, I'm assuming you're also calculating the image size as well.
First, try to set your ImageView
scale type to fitCenter
, or any scale type that fits your needs. Example of scale types are shown below, taken from here:
Later, programmatically change your ImageView
width and height based on the calculations you made.
This way you'll be able to display all the images.
Upvotes: 2