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.

Problems with view's visibilities in RecyclerView (View.GONE)

See original GitHub issue

Issue Description

I have a scenario of test where I need the check if a specific view of an item of RecyclerView.Adapter was setted with visibility = View.GONE, so this is my assert:

recyclerView( {
    atPosition(1) {
        notExist { id( }

but when a run this code above the test fail. I made some asserts to verify the visibility of the and always return the visibility = View.GONE.

I tried to use notDisplayed, but I got the same result.

The curious point is, when my RecyclerView has only one item and I used notExist { id( } without the recycler view wrapper (recyclerView(<id>) { ... }) it worked.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

iammini5commented, May 4, 2018

My case is similar:

recyclerView( {
    atPosition(1) {
        notSwitchOn { id( }

I don’t think your response is related to the issue, actually i added a customized matcher in RecyclerViewMethods.

fun notSwitchOn(func: BaseMatchersImpl.() -> BaseMatchersImpl): Interactions {
            BaseViewInteractions(false, itemMatchList(func)).check(CustomerMatcher.SwitchOff())
            return this

I can find that when matchSafely is called inside my CustomerMatcher, it is not passing the matched childview but the recyclerView itself.

 override fun matchesSafely(item: View): Boolean {
                return (item as Checkable).isChecked() == false

heitorcolangelocommented, Sep 23, 2018

Well, after spending a lot of time on this bug and not getting into a solution, I’ve created new methods so we can match the child views in a RecyclerView item. Unfortunately, now we can only use the child viewId and not all the other attributes that we had (text, contentDescription, etc.).

Here is the PR with the work around for that issue: This should allow people to match child views in a recycler view item safely, but only using the view Id.

Need help to investigate this and came up with a proper solution 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visibility of items not working in recyclerView - Stack Overflow
So let's consider a scenario when we end up with having no image on view. Item at position 0 should show up icon...
Read more >
Reveal or hide a view using animation - Android Developers
Initially hide the content view. contentView.visibility = View.GONE // Retrieve and cache the system's default "short" animation time.
Read more >
Applying Data Binding for Views | CodePath Android Cliffnotes
If you see an error message such as cannot resolve symbol 'ActivityMainBinding' then this means that the data binding auto-generated class has not...
Read more >
MotionLayout: setting visibility programatically at runtime not ...
but with two modifications - my RecyclerView is in SwipeRefreshLayout and one more view to show it only while refresh is going, thus...
Read more >
android-recyclerview item visibility=gone
Visibility is determined not just by the View#setVisibility(int) state of views, but also whether views exist in the current view hierarchy. The class...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found