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...

my current ui

here's image of i'm trying achieve...

my target ui

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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -