android - Setting minimum width of a RecyclerView item -
i trying set minimum width items of recyclerview gridmanagerlayout
if put 5 items per row looks great when put 20 items per row size of item 20 dp want @ least 120 dp, how can that?
gridlayoutmanager manager = new gridlayoutmanager(actividadescolectivasplazasactivity.this, columnas); adapter = new plazasadapter(ctx, listaplazas); mrecyclerview.setlayoutmanager(manager); mrecyclerview.sethasfixedsize(true);
layout
<horizontalscrollview android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@+id/app_bar"> <linearlayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="match_parent"> <view android:layout_width="wrap_content" android:layout_height="fill_parent" class="android.support.v7.widget.recyclerview" android:layout_margintop="10dp" android:minwidth="500dp" android:id="@+id/recycler_view" /> </linearlayout> </horizontalscrollview>
adapter xml
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="80dp" android:minwidth="120dp" android:background="@drawable/fondo_stroke_gris" android:orientation="vertical" android:gravity="center" tools:context="com.psapp_provisport.activity.menuactivity" > <relativelayout android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_margintop="10dp" android:layout_weight="1" > <imageview android:id="@+id/imagen" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_centerhorizontal="true" android:src="@drawable/ic_launcher"/> <progressbar android:id="@+id/pb1" style="?android:attr/progressbarstylelarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:visibility="invisible" /> </relativelayout> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="5dp" android:layout_marginbottom="5dp" android:gravity="center" android:id="@+id/nombre" />
to acomplish change miniumwidth of recycler view programatically number of columns*300
gridlayoutmanager manager = new gridlayoutmanager(actividadescolectivasplazasactivity.this, columnas); mrecyclerview.setminimumwidth(columnas*300);
Comments
Post a Comment