search

Home  >  Q&A  >  body text

android - 如何得到recyclerview item的宽度?

PHP中文网PHP中文网2771 days ago968

reply all(3)I'll reply

  • 高洛峰

    高洛峰2017-04-17 17:21:56

    Once you get RecyclerView item的视图对象,直接调用getWidth(), you will naturally get its width.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:21:56

    recyclerView.getLayoutManager().getChildAt(0).getHeight();
    Get the item of the specified postition

    reply
    0
  • 阿神

    阿神2017-04-17 17:21:56

    The score of this question was answered:

    1. If the view is ready (i.e. the view is visible), find the ItemView and call getWidth() directly

    2. If the view is not ready, you need to use View#post(Runnable) to achieve it, ----Call getWidth() in run()

    reply
    0
  • Cancelreply