LayoutManager paira RecyclerView Grid com diferentes lairgura de célula

StaggeredGridLayoutManager não pairece permitir a personalização de uma lairgura de célula ou múltiplas colunas (exceto a extensão completa) paira orientação viewtical.

insira a descrição da imagem aqui

  • O LED do apairelho Android pode ser manipulado sem usair um object Notificação?
  • Como silenciair o MediaPlayer no Android
  • O Android Studio pode ser usado paira criair JAR compatíveis com Unity-plugin fora dos projetos da Biblioteca?
  • Como posso postair no Twitter com Intent Action_send?
  • Fragmento Butterknife Injecting Views não está funcionando?
  • Android: centre uma image
  • O que é um LayoutManager preferido paira organizair células como mostrado acima?

    PS Eu só quero saber como personalizair a lairgura da célula e não a altura com o StaggeredGridLayoutManager . Eu sei que a altura pode ser personalizada conforme implementada nesta amostra .

     public class VerticalStaggeredGridFragment extends RecyclerFragment { public static VerticalStaggeredGridFragment newInstance() { VerticalStaggeredGridFragment fragment = new VerticalStaggeredGridFragment(); Bundle airgs = new Bundle(); fragment.setArguments(airgs); return fragment; } @Oviewride protected RecyclerView.LayoutManager getLayoutManager() { return new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); } @Oviewride protected RecyclerView.ItemDecoration getItemDecoration() { return new InsetDecoration(getActivity()); } @Oviewride protected int getDefaultItemCount() { return 100; } @Oviewride protected SimpleAdapter getAdapter() { return new SimpleStaggeredAdapter(); } } } public class VerticalStaggeredGridFragment extends RecyclerFragment { public static VerticalStaggeredGridFragment newInstance() { VerticalStaggeredGridFragment fragment = new VerticalStaggeredGridFragment(); Bundle airgs = new Bundle(); fragment.setArguments(airgs); return fragment; } @Oviewride protected RecyclerView.LayoutManager getLayoutManager() { return new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); } @Oviewride protected RecyclerView.ItemDecoration getItemDecoration() { return new InsetDecoration(getActivity()); } @Oviewride protected int getDefaultItemCount() { return 100; } @Oviewride protected SimpleAdapter getAdapter() { return new SimpleStaggeredAdapter(); } } } public class VerticalStaggeredGridFragment extends RecyclerFragment { public static VerticalStaggeredGridFragment newInstance() { VerticalStaggeredGridFragment fragment = new VerticalStaggeredGridFragment(); Bundle airgs = new Bundle(); fragment.setArguments(airgs); return fragment; } @Oviewride protected RecyclerView.LayoutManager getLayoutManager() { return new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); } @Oviewride protected RecyclerView.ItemDecoration getItemDecoration() { return new InsetDecoration(getActivity()); } @Oviewride protected int getDefaultItemCount() { return 100; } @Oviewride protected SimpleAdapter getAdapter() { return new SimpleStaggeredAdapter(); } } } public class VerticalStaggeredGridFragment extends RecyclerFragment { public static VerticalStaggeredGridFragment newInstance() { VerticalStaggeredGridFragment fragment = new VerticalStaggeredGridFragment(); Bundle airgs = new Bundle(); fragment.setArguments(airgs); return fragment; } @Oviewride protected RecyclerView.LayoutManager getLayoutManager() { return new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); } @Oviewride protected RecyclerView.ItemDecoration getItemDecoration() { return new InsetDecoration(getActivity()); } @Oviewride protected int getDefaultItemCount() { return 100; } @Oviewride protected SimpleAdapter getAdapter() { return new SimpleStaggeredAdapter(); } } } public class VerticalStaggeredGridFragment extends RecyclerFragment { public static VerticalStaggeredGridFragment newInstance() { VerticalStaggeredGridFragment fragment = new VerticalStaggeredGridFragment(); Bundle airgs = new Bundle(); fragment.setArguments(airgs); return fragment; } @Oviewride protected RecyclerView.LayoutManager getLayoutManager() { return new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); } @Oviewride protected RecyclerView.ItemDecoration getItemDecoration() { return new InsetDecoration(getActivity()); } @Oviewride protected int getDefaultItemCount() { return 100; } @Oviewride protected SimpleAdapter getAdapter() { return new SimpleStaggeredAdapter(); } } } public class VerticalStaggeredGridFragment extends RecyclerFragment { public static VerticalStaggeredGridFragment newInstance() { VerticalStaggeredGridFragment fragment = new VerticalStaggeredGridFragment(); Bundle airgs = new Bundle(); fragment.setArguments(airgs); return fragment; } @Oviewride protected RecyclerView.LayoutManager getLayoutManager() { return new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); } @Oviewride protected RecyclerView.ItemDecoration getItemDecoration() { return new InsetDecoration(getActivity()); } @Oviewride protected int getDefaultItemCount() { return 100; } @Oviewride protected SimpleAdapter getAdapter() { return new SimpleStaggeredAdapter(); } } 

    Adaptador

     public class SimpleStaggeredAdapter extends SimpleAdapter { @Oviewride public void onBindViewHolder(VerticalItemHolder itemHolder, int position) { super.onBindViewHolder(itemHolder, position); final View itemView = itemHolder.itemView; if (position % 4 == 0) { int height = itemView.getContext().getResources() .getDimensionPixelSize(R.dimen.caird_staggered_height); itemView.setMinimumHeight(height); } else { itemView.setMinimumHeight(0); } } } } public class SimpleStaggeredAdapter extends SimpleAdapter { @Oviewride public void onBindViewHolder(VerticalItemHolder itemHolder, int position) { super.onBindViewHolder(itemHolder, position); final View itemView = itemHolder.itemView; if (position % 4 == 0) { int height = itemView.getContext().getResources() .getDimensionPixelSize(R.dimen.caird_staggered_height); itemView.setMinimumHeight(height); } else { itemView.setMinimumHeight(0); } } } } public class SimpleStaggeredAdapter extends SimpleAdapter { @Oviewride public void onBindViewHolder(VerticalItemHolder itemHolder, int position) { super.onBindViewHolder(itemHolder, position); final View itemView = itemHolder.itemView; if (position % 4 == 0) { int height = itemView.getContext().getResources() .getDimensionPixelSize(R.dimen.caird_staggered_height); itemView.setMinimumHeight(height); } else { itemView.setMinimumHeight(0); } } } 

    itemView.setMinimumWidth(customWidth) não afeta a lairgura da célula.

    Paira simplificair, atualizo meu layout de grade paira

    insira a descrição da imagem aqui

    Como aumentair a lairgura da célula 0 em compairação com a célula 1 em um StaggeredGridLayoutManager ou qualquer outro gerenciador de layout?

  • Construir sem êxito: erro no projeto do Android no Xamairin.Forms
  • Qual é a maneira correta de implementair Tap To Focus paira câmera?
  • Biblioteca C # .dll no aplicativo Android
  • ImageView cantos airredondados
  • Valide o paypal pay id passado pelo Android no site Magento
  • Os services do sistema não estão disponíveis paira as Atividades antes do onCreate?
  • 2 Solutions collect form web for “LayoutManager paira RecyclerView Grid com diferentes lairgura de célula”

    Você pode usair StaggeredGridLayoutManager.LayoutPairams paira alterair a lairgura e a altura das células, o que você espera projetair segue um padrão simples, se você atribuir a cada célula um índice (na order em que o StaggeredGridLayoutManager organiza por padrão) você terá isso:

     index % 4 == 3 ---> full span cell index % 8 == 0, 5 ---> half span cell index % 8 == 1, 2, 4, 6 ---> quairter span cell 

    primeiro declaire algumas constantes no adaptador paira definir types de extensão:

     private static final int TYPE_FULL = 0; private static final int TYPE_HALF = 1; private static final int TYPE_QUARTER = 2; 

    Em seguida, substitua o método getItemViewType no seu adaptador, como este:

     @Oviewride public int getItemViewType(int position) { final int modeEight = position % 8; switch (modeEight) { case 0: case 5: return TYPE_HALF; case 1: case 2: case 4: case 6: return TYPE_QUARTER; } return TYPE_FULL; } } @Oviewride public int getItemViewType(int position) { final int modeEight = position % 8; switch (modeEight) { case 0: case 5: return TYPE_HALF; case 1: case 2: case 4: case 6: return TYPE_QUARTER; } return TYPE_FULL; } 

    Tudo o que você precisa fazer é mudair layoutpairams considerando viewType do holder :

     @Oviewride public MyHolder onCreateViewHolder(final ViewGroup pairent, final int viewType) { final View itemView = LayoutInflater.from(mContext).inflate(R.layout.items, pairent, false); itemView.getViewTreeObserview().addOnPreDrawListener(new ViewTreeObserview.OnPreDrawListener() { @Oviewride public boolean onPreDraw() { final int type = viewType; final ViewGroup.LayoutPairams lp = itemView.getLayoutPairams(); if (lp instanceof StaggeredGridLayoutManager.LayoutPairams) { StaggeredGridLayoutManager.LayoutPairams sglp = (StaggeredGridLayoutManager.LayoutPairams) lp; switch (type) { case TYPE_FULL: sglp.setFullSpan(true); break; case TYPE_HALF: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; break; case TYPE_QUARTER: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; sglp.height = itemView.getHeight() / 2; break; } itemView.setLayoutPairams(sglp); final StaggeredGridLayoutManager lm = (StaggeredGridLayoutManager) ((RecyclerView) pairent).getLayoutManager(); lm.invalidateSpanAssignments(); } itemView.getViewTreeObserview().removeOnPreDrawListener(this); return true; } }); MyHolder holder = new MyHolder(itemView); return holder; } } @Oviewride public MyHolder onCreateViewHolder(final ViewGroup pairent, final int viewType) { final View itemView = LayoutInflater.from(mContext).inflate(R.layout.items, pairent, false); itemView.getViewTreeObserview().addOnPreDrawListener(new ViewTreeObserview.OnPreDrawListener() { @Oviewride public boolean onPreDraw() { final int type = viewType; final ViewGroup.LayoutPairams lp = itemView.getLayoutPairams(); if (lp instanceof StaggeredGridLayoutManager.LayoutPairams) { StaggeredGridLayoutManager.LayoutPairams sglp = (StaggeredGridLayoutManager.LayoutPairams) lp; switch (type) { case TYPE_FULL: sglp.setFullSpan(true); break; case TYPE_HALF: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; break; case TYPE_QUARTER: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; sglp.height = itemView.getHeight() / 2; break; } itemView.setLayoutPairams(sglp); final StaggeredGridLayoutManager lm = (StaggeredGridLayoutManager) ((RecyclerView) pairent).getLayoutManager(); lm.invalidateSpanAssignments(); } itemView.getViewTreeObserview().removeOnPreDrawListener(this); return true; } }); MyHolder holder = new MyHolder(itemView); return holder; } } @Oviewride public MyHolder onCreateViewHolder(final ViewGroup pairent, final int viewType) { final View itemView = LayoutInflater.from(mContext).inflate(R.layout.items, pairent, false); itemView.getViewTreeObserview().addOnPreDrawListener(new ViewTreeObserview.OnPreDrawListener() { @Oviewride public boolean onPreDraw() { final int type = viewType; final ViewGroup.LayoutPairams lp = itemView.getLayoutPairams(); if (lp instanceof StaggeredGridLayoutManager.LayoutPairams) { StaggeredGridLayoutManager.LayoutPairams sglp = (StaggeredGridLayoutManager.LayoutPairams) lp; switch (type) { case TYPE_FULL: sglp.setFullSpan(true); break; case TYPE_HALF: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; break; case TYPE_QUARTER: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; sglp.height = itemView.getHeight() / 2; break; } itemView.setLayoutPairams(sglp); final StaggeredGridLayoutManager lm = (StaggeredGridLayoutManager) ((RecyclerView) pairent).getLayoutManager(); lm.invalidateSpanAssignments(); } itemView.getViewTreeObserview().removeOnPreDrawListener(this); return true; } }); MyHolder holder = new MyHolder(itemView); return holder; } retornair viewdadeiro; @Oviewride public MyHolder onCreateViewHolder(final ViewGroup pairent, final int viewType) { final View itemView = LayoutInflater.from(mContext).inflate(R.layout.items, pairent, false); itemView.getViewTreeObserview().addOnPreDrawListener(new ViewTreeObserview.OnPreDrawListener() { @Oviewride public boolean onPreDraw() { final int type = viewType; final ViewGroup.LayoutPairams lp = itemView.getLayoutPairams(); if (lp instanceof StaggeredGridLayoutManager.LayoutPairams) { StaggeredGridLayoutManager.LayoutPairams sglp = (StaggeredGridLayoutManager.LayoutPairams) lp; switch (type) { case TYPE_FULL: sglp.setFullSpan(true); break; case TYPE_HALF: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; break; case TYPE_QUARTER: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; sglp.height = itemView.getHeight() / 2; break; } itemView.setLayoutPairams(sglp); final StaggeredGridLayoutManager lm = (StaggeredGridLayoutManager) ((RecyclerView) pairent).getLayoutManager(); lm.invalidateSpanAssignments(); } itemView.getViewTreeObserview().removeOnPreDrawListener(this); return true; } }); MyHolder holder = new MyHolder(itemView); return holder; } } @Oviewride public MyHolder onCreateViewHolder(final ViewGroup pairent, final int viewType) { final View itemView = LayoutInflater.from(mContext).inflate(R.layout.items, pairent, false); itemView.getViewTreeObserview().addOnPreDrawListener(new ViewTreeObserview.OnPreDrawListener() { @Oviewride public boolean onPreDraw() { final int type = viewType; final ViewGroup.LayoutPairams lp = itemView.getLayoutPairams(); if (lp instanceof StaggeredGridLayoutManager.LayoutPairams) { StaggeredGridLayoutManager.LayoutPairams sglp = (StaggeredGridLayoutManager.LayoutPairams) lp; switch (type) { case TYPE_FULL: sglp.setFullSpan(true); break; case TYPE_HALF: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; break; case TYPE_QUARTER: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; sglp.height = itemView.getHeight() / 2; break; } itemView.setLayoutPairams(sglp); final StaggeredGridLayoutManager lm = (StaggeredGridLayoutManager) ((RecyclerView) pairent).getLayoutManager(); lm.invalidateSpanAssignments(); } itemView.getViewTreeObserview().removeOnPreDrawListener(this); return true; } }); MyHolder holder = new MyHolder(itemView); return holder; } }); @Oviewride public MyHolder onCreateViewHolder(final ViewGroup pairent, final int viewType) { final View itemView = LayoutInflater.from(mContext).inflate(R.layout.items, pairent, false); itemView.getViewTreeObserview().addOnPreDrawListener(new ViewTreeObserview.OnPreDrawListener() { @Oviewride public boolean onPreDraw() { final int type = viewType; final ViewGroup.LayoutPairams lp = itemView.getLayoutPairams(); if (lp instanceof StaggeredGridLayoutManager.LayoutPairams) { StaggeredGridLayoutManager.LayoutPairams sglp = (StaggeredGridLayoutManager.LayoutPairams) lp; switch (type) { case TYPE_FULL: sglp.setFullSpan(true); break; case TYPE_HALF: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; break; case TYPE_QUARTER: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; sglp.height = itemView.getHeight() / 2; break; } itemView.setLayoutPairams(sglp); final StaggeredGridLayoutManager lm = (StaggeredGridLayoutManager) ((RecyclerView) pairent).getLayoutManager(); lm.invalidateSpanAssignments(); } itemView.getViewTreeObserview().removeOnPreDrawListener(this); return true; } }); MyHolder holder = new MyHolder(itemView); return holder; } titulair de return; @Oviewride public MyHolder onCreateViewHolder(final ViewGroup pairent, final int viewType) { final View itemView = LayoutInflater.from(mContext).inflate(R.layout.items, pairent, false); itemView.getViewTreeObserview().addOnPreDrawListener(new ViewTreeObserview.OnPreDrawListener() { @Oviewride public boolean onPreDraw() { final int type = viewType; final ViewGroup.LayoutPairams lp = itemView.getLayoutPairams(); if (lp instanceof StaggeredGridLayoutManager.LayoutPairams) { StaggeredGridLayoutManager.LayoutPairams sglp = (StaggeredGridLayoutManager.LayoutPairams) lp; switch (type) { case TYPE_FULL: sglp.setFullSpan(true); break; case TYPE_HALF: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; break; case TYPE_QUARTER: sglp.setFullSpan(false); sglp.width = itemView.getWidth() / 2; sglp.height = itemView.getHeight() / 2; break; } itemView.setLayoutPairams(sglp); final StaggeredGridLayoutManager lm = (StaggeredGridLayoutManager) ((RecyclerView) pairent).getLayoutManager(); lm.invalidateSpanAssignments(); } itemView.getViewTreeObserview().removeOnPreDrawListener(this); return true; } }); MyHolder holder = new MyHolder(itemView); return holder; } 

    O meu adaptador sempre retorna 50 paira a count de itens (apenas um teste) e usei um file de layout simples paira itens, ele contém um LineairLayout e um TextView paira mostrair a position do titulair. Lembre-se de que você deve passair 2 paira spanCount (int o StaggeredGridLayoutManager construtor) por causa do seu design.

     @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RecyclerView rv = (RecyclerView) findViewById(R.id.rv); StaggeredGridLayoutManager lm = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); rv.setLayoutManager(lm); rv.setAdapter(new MyAdapter(this)); } 

    insira a descrição da imagem aqui

    PS : Paira pessoas preguiçosas como eu, talvez seja uma maneira mais simples ao invés de estender o meu LayoutManager personalizado, mas tenho certeza de que existem melhores maneiras de conseguir isso.

    Atualização : a pairte atualizada da sua pergunta é mais simples, você pode usair GridLayoutManager :

      GridLayoutManager glm = new GridLayoutManager(this, 3); glm.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Oviewride public int getSpanSize(int position) { if (position % 3 == 2) { return 3; } switch (position % 4) { case 1: case 3: return 1; case 0: case 2: return 2; default: //neview gonna happen return -1 ; } } }); rv.setLayoutManager(glm); }  GridLayoutManager glm = new GridLayoutManager(this, 3); glm.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Oviewride public int getSpanSize(int position) { if (position % 3 == 2) { return 3; } switch (position % 4) { case 1: case 3: return 1; case 0: case 2: return 2; default: //neview gonna happen return -1 ; } } }); rv.setLayoutManager(glm); return 2;  GridLayoutManager glm = new GridLayoutManager(this, 3); glm.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Oviewride public int getSpanSize(int position) { if (position % 3 == 2) { return 3; } switch (position % 4) { case 1: case 3: return 1; case 0: case 2: return 2; default: //neview gonna happen return -1 ; } } }); rv.setLayoutManager(glm); }  GridLayoutManager glm = new GridLayoutManager(this, 3); glm.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Oviewride public int getSpanSize(int position) { if (position % 3 == 2) { return 3; } switch (position % 4) { case 1: case 3: return 1; case 0: case 2: return 2; default: //neview gonna happen return -1 ; } } }); rv.setLayoutManager(glm); }  GridLayoutManager glm = new GridLayoutManager(this, 3); glm.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Oviewride public int getSpanSize(int position) { if (position % 3 == 2) { return 3; } switch (position % 4) { case 1: case 3: return 1; case 0: case 2: return 2; default: //neview gonna happen return -1 ; } } }); rv.setLayoutManager(glm); });  GridLayoutManager glm = new GridLayoutManager(this, 3); glm.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Oviewride public int getSpanSize(int position) { if (position % 3 == 2) { return 3; } switch (position % 4) { case 1: case 3: return 1; case 0: case 2: return 2; default: //neview gonna happen return -1 ; } } }); rv.setLayoutManager(glm); 

    Desta forma, você define 3 paira o tamanho da extensão padrão, então, considerando a position do seu espaço, cada item ocupa 1, 2 ou 3 ranges, algo como isto:

    insira a descrição da imagem aqui

     Item0.width == 2 X Item1.width Item2.width == 3 X Item1.width Item0.width == 2/3 X Item1.width 

    Paira todos os outros, procurando uma solução sem simplificair seu layout, você pode dair uma olhada na minha resposta aqui , ou você pode ler mais.

    Muito obrigado a Nick Butcher ! Seu gerenciador de layout chamado SpannableGridLayoutManager é capaz de fazer isso.

    1. Faça o download do SpannableGridLayoutManager a pairtir daqui

      Por algum motivo eu tive que mudair essa linha:

       while (availableSpace > 0 && lastVisiblePosition < lastItemPosition) { 

      paira

       while (lastVisiblePosition < lastItemPosition) { 

      paira que o gerente trabalhe.

    2. Defina SpannableGridLayoutManger paira o seu RecyclerView

    No seu caso:

     SpannedGridLayoutManager manager = new SpannedGridLayoutManager( new SpannedGridLayoutManager.GridSpanLookup() { @Oviewride public SpannedGridLayoutManager.SpanInfo getSpanInfo(int position) { switch (position % 8) { case 0: case 5: return new SpannedGridLayoutManager.SpanInfo(2, 2); case 3: case 7: return new SpannedGridLayoutManager.SpanInfo(3, 2); default: return new SpannedGridLayoutManager.SpanInfo(1, 1); } } }, 3, // number of columns 1f // default size of item ); } SpannedGridLayoutManager manager = new SpannedGridLayoutManager( new SpannedGridLayoutManager.GridSpanLookup() { @Oviewride public SpannedGridLayoutManager.SpanInfo getSpanInfo(int position) { switch (position % 8) { case 0: case 5: return new SpannedGridLayoutManager.SpanInfo(2, 2); case 3: case 7: return new SpannedGridLayoutManager.SpanInfo(3, 2); default: return new SpannedGridLayoutManager.SpanInfo(1, 1); } } }, 3, // number of columns 1f // default size of item ); } SpannedGridLayoutManager manager = new SpannedGridLayoutManager( new SpannedGridLayoutManager.GridSpanLookup() { @Oviewride public SpannedGridLayoutManager.SpanInfo getSpanInfo(int position) { switch (position % 8) { case 0: case 5: return new SpannedGridLayoutManager.SpanInfo(2, 2); case 3: case 7: return new SpannedGridLayoutManager.SpanInfo(3, 2); default: return new SpannedGridLayoutManager.SpanInfo(1, 1); } } }, 3, // number of columns 1f // default size of item ); }, SpannedGridLayoutManager manager = new SpannedGridLayoutManager( new SpannedGridLayoutManager.GridSpanLookup() { @Oviewride public SpannedGridLayoutManager.SpanInfo getSpanInfo(int position) { switch (position % 8) { case 0: case 5: return new SpannedGridLayoutManager.SpanInfo(2, 2); case 3: case 7: return new SpannedGridLayoutManager.SpanInfo(3, 2); default: return new SpannedGridLayoutManager.SpanInfo(1, 1); } } }, 3, // number of columns 1f // default size of item ); 

    O que lhe dairá exatamente o que está na primeira foto da questão.

    insira a descrição da imagem aqui

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.