RecyclerView item height and width change dynamically Android

后端 未结 2 396
渐次进展
渐次进展 2021-02-01 23:28

I am new to android development and I am developing an app where the app downloads pictures from server and show them in a gridView. But some extra spaces are coming up when the

2条回答
  •  时光说笑
    2021-02-01 23:44

    for those who want to do it in the xml layout (recyclerView item) file you can use a ConstraintLayout by combining

                android:layout_width="match_parent"
                android:layout_height="wrap_content"
    

    and the following code for having a square item

                app:layout_constraintDimensionRatio="4:4"
    

    and don't forget to provide all the constraint that way you can set

                android:layout_width="0dp"
                android:layout_height="0dp"
    

    hence the complete code will be as follow

    
    
            
    
    

提交回复
热议问题