android - LayoutManager for RecyclerView to set the number of columns automatically according to width of items -
i'm trying build ui involving recyclerview or gridview, want set number of columns automatically depending upon number , width of items i'm populating dynamically.
here's image of i've achieved far...
here's image of i'm trying achieve...
my item layout xml
<textview android:layout_width="wrap_content" android:layout_height="40dp" android:background="@drawable/hollow_white_background" android:id="@+id/fooditemname" android:text="pizza" android:gravity="center" android:textcolor="@color/colorgray300" android:textstyle="bold" android:textsize="15sp" android:paddingleft="10dp" android:paddingright="10dp" />
please help!
in xml file, add android:numcolumns="auto_fit" , android:stretchmode="columnwidth" attributes gridview. first attribute decides how many columns there should depending on screen size, , second attribute decides space left, in case increases column widths.
Comments
Post a Comment