Why does LayoutInflater ignore the layout_width and layout_height layout parameters I've specified?

前端 未结 3 1825
终归单人心
终归单人心 2020-11-22 12:59

I\'ve had severe trouble getting LayoutInflater to work as expected, and so did other people: How to use layoutinflator to add views at runtime?.

Why does LayoutInfl

3条回答
  •  一整个雨季
    2020-11-22 13:24

    wanna add to main answer above
    I tried to follow it but my recyclerView began to stretch every item to a screen
    I had to add next line after inflating for reach to goal

    itemLayoutView.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
    

    I already added these params by xml but it didnot work correctly
    and with this line all is ok

提交回复
热议问题