Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
144 views
in Technique[技术] by (71.8m points)

Android Kotlin Glide Image Sizes Change when Scrolling

I am using Glide for Kotlin from Google as part of the Firebase suite. I'm downloading jpg photos from Firebase.

implementation 'com.firebaseui:firebase-ui-storage:6.4.0'

When I sroll, the images change size. The faster I scroll, the smaller some images get. I tried fitCenter() but that didnt seem to help.

        Glide.with(context!! /* context */)
            .load(figure.imagePrimaryFrontURLString)
            .apply(
                RequestOptions()
                    .placeholder(R.drawable.mytoybox_logo)
                    .fitCenter()
            )
            .into(holder.imageViewFigure)

Fragment Layout

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <include
            android:id="@+id/figure_photoFilters"
            layout="@layout/figure_filters"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="4dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <SearchView
            android:id="@+id/searchView_FigurePhoto"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/figure_photoFilters" />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/figurePhotoList_RecyclerView"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginBottom="60dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/searchView_FigurePhoto" />

        <include
            android:id="@+id/progressBarWText"
            layout="@layout/progress_bar_with_text"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:visibility="gone"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            app:adSize="BANNER"
            app:adUnitId="xxx"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/figurePhotoList_RecyclerView">
        </com.google.android.gms.ads.AdView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

RecycleView Row Layout

<?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:orientation="horizontal"
    android:padding="8dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/imageView_Figure"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="fitXY"
        android:adjustViewBounds="true"
        android:contentDescription="@string/figure_image"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:srcCompat="@drawable/mytoybox_logo" />

    <include
        android:id="@+id/layout_specifics_icons"
        layout="@layout/specifics_icons"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="@id/imageView_Figure"
        app:layout_constraintTop_toTopOf="@id/imageView_Figure" />

    <TextView
        android:id="@+id/textView_Number"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:textAlignment="center"
        android:paddingStart="4dp"
        android:paddingEnd="4dp"
        android:background="@drawable/rounded_text_back"
        android:textColor="@color/primaryTextColor"
        app:layout_constraintStart_toStartOf="@+id/imageView_Figure"
        app:layout_constraintTop_toTopOf="@+id/imageView_Figure" />

    <TextView
        android:id="@+id/textView_Figure_Name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:gravity="center_horizontal|top"
        android:textSize="12sp"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView_Figure"
        tools:text="Figure Name" />

    <TextView
        android:id="@+id/textView_Series_Name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:gravity="center_horizontal|top"
        android:textSize="10sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView_Figure_Name"
        tools:text="Figure Name" />

</androidx.constraintlayout.widget.ConstraintLayout>

Specifics Icons

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:orientation="vertical"
    android:id="@+id/specifics_icons"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <TextView
        android:id="@+id/textView_HaveIcon"
        android:layout_width="25dp"
        android:layout_height="25dp"
        android:textAlignment="center"
        android:paddingStart="4dp"
        android:paddingEnd="4dp"
        android:background="@drawable/check_white_on_green"
        android:textColor="@color/primaryTextColor"
        android:visibility="gone"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/textView_WantIcon"
        android:layout_width="25dp"
        android:layout_height="25dp"
        android:textAlignment="center"
        android:paddingStart="4dp"
        android:paddingEnd="4dp"
        android:background="@drawable/w_white_on_purple"
        android:textColor="@color/primaryTextColor"
        android:visibility="gone"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView_HaveIcon" />

    <TextView
        android:id="@+id/textView_SellIcon"
        android:layout_width="25dp"
        android:layout_height="25dp"
        android:textAlignment="center"
        android:paddingStart="4dp"
        android:paddingEnd="4dp"
        android:background="@drawable/s_white_on_blue"
        android:textColor="@color/primaryTextColor"
        android:visibility="gone"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView_WantIcon" />

    <TextView
        android:id="@+id/textView_OrderIcon"
        android:layout_width="25dp"
        android:layout_height="25dp"
        android:textAlignment="center"
        android:paddingStart="4dp"
        android:paddingEnd="4dp"
        android:background="@drawable/o_white_on_orange"
        android:textColor="@color/primaryTextColor"
        android:visibility="gone"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView_SellIcon" />

</LinearLayout>

Photo 1

Photo 2

Photo 3

question from:https://stackoverflow.com/questions/65648772/android-kotlin-glide-image-sizes-change-when-scrolling

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...