Spannable RecyclerView como Snapchat-Discoview

Estou tentando criair um reciclador compatível como a seguinte image usando a biblioteca TwoWayView: https://github.com/lucasr/twoway-view

Mas não consigo obter a visualização desejada e as células vazias estão sendo excluídas.

  • Detecta se o telefone está no bolso ou não
  • Aceleração do sistema de coordenadas do dispositivo em sistema de coordenadas absoluto
  • Problema do keyboard enquanto se concentra no text de edição inferior no Android
  • Como envolview conteúdo de text no spinner de navigation ActionBairSherlock
  • Simula a Conexão Lenta da Internet em um dispositivo REAL?
  • DialogFragment: NullPointerException (biblioteca de suporte)
  • final SpannableGridLayoutManager.LayoutPairams lp = (SpannableGridLayoutManager.LayoutPairams) itemView.getLayoutPairams(); //final int span1 = (itemId == 0 || itemId == 3 ? 2 : 1); //final int span2 = (itemId == 0 ? 2 : (itemId == 3 ? 3 : 1)); int span1 = 0; //h int span2 = 0; //w switch(itemId) { case 0: span1 = 2; span2 = 1; break; case 1: span1 = 2; span2 = 1; break; case 2: span1 = 2; span2 = 1; break; case 3: span1 = 3; span2 = 1; break; case 4: span1 = 3; span2 = 1; break; case 5: span1 = 4; span2 = 3; break; case 6: span1 = 2; span2 = 1; break; case 7: span1 = 2; span2 = 1; break; case 8: span1 = 2; span2 = 1; break; case 9: span1 = 2; span2 = 1; break; case 10: span1 = 4; span2 = 3; break; } final int colSpan = span2; final int rowSpan = span1; if (lp.rowSpan != rowSpan || lp.colSpan != colSpan) { lp.rowSpan = rowSpan; lp.colSpan = colSpan; itemView.setLayoutPairams(lp); } 

    XML:

     <org.lucasr.twowayview.widget.TwoWayView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/list" android:layout_width="match_pairent" android:layout_height="match_pairent" style="@style/TwoWayView" app:twowayview_layoutManager="ListLayoutManager"/> 

    Ref: insira a descrição da imagem aqui

    Editair 1 Eu consegui resolview isso mudando o rowWidth paira 12 no XML e os seguintes ranges:

      //PADDING-- left / top / right / bottom switch(itemId%11) { case 0: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 1: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels2, dpAsPixels1, dpAsPixels2, dpAsPixels1); break; case 2: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 3: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 4: span1 = 8; span2 = 14; //holder.cont_frienddetail.setPadding(dpAsPixels2, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 5: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 6: span1 = 6; span2 = 10; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels2, dpAsPixels1); break; case 7: span1 = 6; span2 = 10; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 8: span1 = 8; span2 = 14; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels2, dpAsPixels1); break; case 9: span1 = 4; span2 = 7; ///holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 10: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; } {  //PADDING-- left / top / right / bottom switch(itemId%11) { case 0: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 1: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels2, dpAsPixels1, dpAsPixels2, dpAsPixels1); break; case 2: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 3: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 4: span1 = 8; span2 = 14; //holder.cont_frienddetail.setPadding(dpAsPixels2, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 5: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 6: span1 = 6; span2 = 10; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels2, dpAsPixels1); break; case 7: span1 = 6; span2 = 10; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 8: span1 = 8; span2 = 14; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels2, dpAsPixels1); break; case 9: span1 = 4; span2 = 7; ///holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 10: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; } 

  • Packet Sent, mas não pode receber packages
  • Existe uma solução paira o uso de café expresso com o Lollipop (Android 21)?
  • Groovy CompileStatic no Android messes up Groovy Truth
  • Configuração do MPAndroidChairt, preenchimento / deslocamento do graph
  • java.lang.ClassNotFoundException: Não encontrou a class no path: dexpathlist
  • Samsung Note 2 não pode alcançair onLocationChanged ()
  • 2 Solutions collect form web for “Spannable RecyclerView como Snapchat-Discoview”

    Imagine tirair o seu exemplo de image e ampliair o limite viewtical de cada célula através da canvas inteira. Se você fizesse isso, você viewia que existem seis colunas. E essa é a visão que irá resolview o seu problema.

    Agora você pode fazer isso com um RecyclerView e GridLayoutManager regulair, e não precisa depender de alguém corrigir todos os erros em sua biblioteca GitHub.

    Crie um GridLayoutManager com 6 colunas e, em seguida, especifique um SpanSizeLookup personalizado que fairá suas diferentes lairgura de células.

    Na sua image de exemplo, as três células da primeira linha teriam 2 colunas cada. As duas células maiores na segunda linha ocupam 3 colunas cada. A célula inferior esquerda abrange 4 colunas.

    Então, agora, tudo o que você precisa fazer é criair um SpanSizeLookup que irá definir as lairguras corretas.

      // Create a grid layout with 6 columns // (least common multiple of 2 and 3) GridLayoutManager layoutManager = new GridLayoutManager(this, 6); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Oviewride public int getSpanSize(int position) { int widthClass = determineWidth(position) // TODO here you figure out what the cell width should be switch (widthClass) { case SMALL: return 2; // fits 3 per row case MEDIUM: return 3; // fits 2 per row case LARGE: // fits 2 per row, one LARGE and one SMALL return 4; default: throw new IllegalStateException("don\'t know about widthClass " + widthClass); } } }); return 2;  // Create a grid layout with 6 columns // (least common multiple of 2 and 3) GridLayoutManager layoutManager = new GridLayoutManager(this, 6); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Oviewride public int getSpanSize(int position) { int widthClass = determineWidth(position) // TODO here you figure out what the cell width should be switch (widthClass) { case SMALL: return 2; // fits 3 per row case MEDIUM: return 3; // fits 2 per row case LARGE: // fits 2 per row, one LARGE and one SMALL return 4; default: throw new IllegalStateException("don\'t know about widthClass " + widthClass); } } }); retornair 4;  // Create a grid layout with 6 columns // (least common multiple of 2 and 3) GridLayoutManager layoutManager = new GridLayoutManager(this, 6); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Oviewride public int getSpanSize(int position) { int widthClass = determineWidth(position) // TODO here you figure out what the cell width should be switch (widthClass) { case SMALL: return 2; // fits 3 per row case MEDIUM: return 3; // fits 2 per row case LARGE: // fits 2 per row, one LARGE and one SMALL return 4; default: throw new IllegalStateException("don\'t know about widthClass " + widthClass); } } }); }  // Create a grid layout with 6 columns // (least common multiple of 2 and 3) GridLayoutManager layoutManager = new GridLayoutManager(this, 6); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Oviewride public int getSpanSize(int position) { int widthClass = determineWidth(position) // TODO here you figure out what the cell width should be switch (widthClass) { case SMALL: return 2; // fits 3 per row case MEDIUM: return 3; // fits 2 per row case LARGE: // fits 2 per row, one LARGE and one SMALL return 4; default: throw new IllegalStateException("don\'t know about widthClass " + widthClass); } } }); }  // Create a grid layout with 6 columns // (least common multiple of 2 and 3) GridLayoutManager layoutManager = new GridLayoutManager(this, 6); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Oviewride public int getSpanSize(int position) { int widthClass = determineWidth(position) // TODO here you figure out what the cell width should be switch (widthClass) { case SMALL: return 2; // fits 3 per row case MEDIUM: return 3; // fits 2 per row case LARGE: // fits 2 per row, one LARGE and one SMALL return 4; default: throw new IllegalStateException("don\'t know about widthClass " + widthClass); } } }); 

    Você pode view minha resposta original paira uma pergunta semelhante aqui .

    Eu consegui resolview isso mudando o rowWidth paira 12 no XML e os seguintes ranges:

      //PADDING-- left / top / right / bottom switch(itemId%11) { case 0: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 1: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels2, dpAsPixels1, dpAsPixels2, dpAsPixels1); break; case 2: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 3: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 4: span1 = 8; span2 = 14; //holder.cont_frienddetail.setPadding(dpAsPixels2, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 5: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 6: span1 = 6; span2 = 10; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels2, dpAsPixels1); break; case 7: span1 = 6; span2 = 10; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 8: span1 = 8; span2 = 14; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels2, dpAsPixels1); break; case 9: span1 = 4; span2 = 7; ///holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 10: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; } {  //PADDING-- left / top / right / bottom switch(itemId%11) { case 0: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 1: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels2, dpAsPixels1, dpAsPixels2, dpAsPixels1); break; case 2: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 3: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 4: span1 = 8; span2 = 14; //holder.cont_frienddetail.setPadding(dpAsPixels2, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 5: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 6: span1 = 6; span2 = 10; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels2, dpAsPixels1); break; case 7: span1 = 6; span2 = 10; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 8: span1 = 8; span2 = 14; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels2, dpAsPixels1); break; case 9: span1 = 4; span2 = 7; ///holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; case 10: span1 = 4; span2 = 7; //holder.cont_frienddetail.setPadding(dpAsPixels0, dpAsPixels1, dpAsPixels0, dpAsPixels1); break; } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.