How to fix view that is misplaced and only comes to right place after I scroll inside the RecyclerView

丶灬走出姿态 提交于 2019-12-24 19:39:16

问题


This is the problem: https://imgur.com/gallery/pRFhG9e?s=wa

I already asked once (How to avoid admob adview being cut off) but didn't get any successful answers.

I have new info that I didn't provide in the previous question. I have realized that the AdView comes back to the right place after I scroll up or down the RecyclerView, so I think the problem is related to the RecyclerView somehow pushing down the AdView.

Some new solutions I have tried inside onResume and have failed:

  • Use .scrollToPosition with the instance of RecyclerView.
  • Use .notifyDataSetChanged with the subclass of RecyclerView.Adapter
  • Call once again mRecyclerView.setAdapter(my adapter subclass)

With all these three attempts I intended to make the RecyclerView scroll without the user having to do it himself so that when he would go back he would automatically see the AdView in place again. As I said, it was a big fail.

来源:https://stackoverflow.com/questions/55050062/how-to-fix-view-that-is-misplaced-and-only-comes-to-right-place-after-i-scroll-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!