Categories: java, android, layout, responsive

Stretch Images to screen size in GridLayout Android

1 answer

I want to strech my cards responisve. I have a GridLayout with 3 columns. The scaleTypes of the cards are fitXY.

How can i autoscale the cards. Somehow android:strechmode isn't found.

Cards

The XML:

<androidx.gridlayout.widget.GridLayout         android:id="@+id/thirdRow"         android:layout_width="0dp"         android:layout_height="wrap_content"         app:columnCount="3"         app:layout_constraintBottom_toBottomOf="parent"         app:layout_constraintEnd_toEndOf="parent"         app:layout_constraintStart_toStartOf="parent"         app:layout_constraintTop_toTopOf="parent"         app:rowCount="1">           <ImageView             android:id="@+id/imageView9"             android:scaleType="fitXY"             app:layout_columnWeight="0"             app:layout_gravity="center"             app:srcCompat="@drawable/back" />          <ImageView             android:id="@+id/imageView10"             android:scaleType="fitXY"             app:layout_columnWeight="0"             app:layout_gravity="center"             app:srcCompat="@drawable/back" />          <ImageView             android:id="@+id/imageView11"             android:scaleType="fitXY"             app:layout_columnWeight="0"             app:layout_gravity="center"             app:srcCompat="@drawable/back" />      </androidx.gridlayout.widget.GridLayout> 

Does somebody has any ideo.

Thank you very much

All answers to this question, which has the identifier 61238361

The best answer:

ConstraintLayout with the use of Horizontal chains offers similar layout control, but with much-improved performance.

<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout 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"     tools:context=".com.example.actorsapp.activity.MainActivity">      <ImageView         android:id="@+id/imageView9"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:scaleType="fitXY"         app:layout_constraintBottom_toBottomOf="parent"         app:layout_constraintEnd_toStartOf="@id/imageView10"         app:layout_constraintStart_toStartOf="parent"         app:layout_constraintTop_toTopOf="parent"         app:srcCompat="@drawable/back" />      <ImageView         android:id="@+id/imageView10"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:scaleType="fitXY"         app:layout_constraintBottom_toBottomOf="@id/imageView9"         app:layout_constraintEnd_toStartOf="@id/imageView11"         app:layout_constraintStart_toEndOf="@id/imageView9"         app:layout_constraintTop_toTopOf="@id/imageView9"         app:srcCompat="@drawable/back" />      <ImageView         android:id="@+id/imageView11"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:scaleType="fitXY"         app:layout_constraintBottom_toBottomOf="@id/imageView9"         app:layout_constraintEnd_toEndOf="parent"         app:layout_constraintStart_toEndOf="@id/imageView10"         app:layout_constraintTop_toTopOf="@id/imageView9"         app:srcCompat="@drawable/back" />  </androidx.constraintlayout.widget.ConstraintLayout> 

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type com.google.firebase.iid.zzav is referenced as an interface from com.google.firebase.messaging.zzd”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data