question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImageView not getting `onSuccess` call if it's in `GONE` state and have one of settings `layout_width`/`layout_height` set as `match_parent`

See original GitHub issue

Describe the bug ImageView not getting onSuccess call if it’s in GONE state and have one of settings layout_width/layout_height set as match_parent.

Expected behavior Listener should get this call 😃

To Reproduce Layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/message_image_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:visibility="gone"
        android:layout_centerInParent="true"/>

</RelativeLayout>

Load:

findViewById<ImageView>(R.id.message_image_view).apply {
  load("https://media.tenor.com/images/07897c06242f1329ef7c37878b6bed94/tenor.png") {
      listener(
              onStart = {
                  Log.e("ZXC", "onStart")
              },
              onSuccess = { _, _ ->
                  Log.e("ZXC", "onSuccess")
                  visibility = View.VISIBLE
              }
      )
  }
}

Version 1.2.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
henningBunkcommented, May 3, 2021

Can confirm. Using wrap_content works. Using match_parent or an equivalent constraint layout does not work.

The onSuccess callback is never called for me. (Neither onError). It does not matter if you set the image view to gone before the request or inside the onStart callback.

Somehow the onStart callback is called twice for me. Dont know if related though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - ImageView - have height match width?
Set the ImageView width to 0dp and constrain its start and end to the parent. I'm not sure if setting the width to...
Read more >
Displaying Images with the Picasso Library
For any given Picasso call, we can fix this by one or more of the following approaches: Add an explicit width or height...
Read more >
ImageView - Android Developers
android:duplicateParentState, When this attribute is set to true, the view gets its drawable state (focused, pressed, etc.) from its direct parent rather ...
Read more >
A guide for Android ImageView ScaleType and ...
When we set adjustViewBounds to true we are telling the ImageView (not the drawable) to adjust its bounds to preserve the aspect ratio...
Read more >
Image Processing with Coil in Android - Section.io
Deploy Containers Close to Your Users. This Engineering Education (EngEd) Program is supported by Section. Instantly deploy containers globally.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found