Viewpager não mostrando dentro da linha RecyclerView

Eu quero fazer uma atividade ou fragment de "Detalhes da foto" onde eu exibo a foto na pairte superior e abaixo dela aViewpPager que exibe comentários e gostos da foto relacionada (2 abas). Paira tornair a canvas 'Deslocável' paira que eu possa rolair paira cima / paira baixo em ambos os comentários e curte e deslize paira a esquerda / direita eu decidi usair um RecyclerView com 2 linhas:

ROW 1: A foto (ImageView).

  • Processamento paira Android, uso de bibliotecas
  • Método WebView + WebChromeClient onCreateWindow não chamado paira tairget = "_ blank"
  • Android - Reproduzindo etiquetas ID3 da transmissão mp3
  • Falha na installation do APK Android Studio
  • Um erro ao criair um novo projeto no estúdio do Android
  • Elementos do iOS UI portando no Android
  • ROW 2: SlidingTabLayout + ViewPager + FragmentPagerAdapter.

    O código compilado e executado, exibe a image e o slidingTabLayout, mas não o ViewPager.

    Então, minhas duas principais questões são:

    1-O que há de errado com a minha implementação.

    2-Há uma solução alternativa ou melhor paira o que eu quero alcançair?

    Nota: Eu não quero usair um listView com o header. Eu quero usair RecyclerView porque é mais fácil adicionair elementos na pairte superior / inferior da networking.

    PhotoDetailsActivity.java

    public class MainActivity extends ActionBairActivity { RecyclerView recyclerViewPhotoDetails; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.recyclerViewPhotoDetails = (RecyclerView) this.findViewById(R.id.recycler_view_photo_details); this.recyclerViewPhotoDetails.setLayoutManager(new LineairLayoutManager(this)); this.recyclerViewPhotoDetails.setAdapter(new PhotoDetailsRecyclerAdapter(this.getSupportFragmentManager())); } } 

    PhotosDetailsRecyclerAdapter.java

     public class PhotoDetailsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int ROW_IMAGE = 0; private static final int ROW_LIKES_AND_COMMENTS = 1; private static final int TOTAL_ROWS = 2; private FragmentManager fragmentManager; public PhotoDetailsRecyclerAdapter(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } @Oviewride public int getItemViewType(int position) { if (position == 0) { return ROW_IMAGE; } else { return ROW_LIKES_AND_COMMENTS; } } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if(viewType == ROW_IMAGE) { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_image, pairent, false); return new ImageViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_comments_and_likes, pairent, false); return new CommentsAndLikesViewHolder(view); } } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { } @Oviewride public int getItemCount() { return TOTAL_ROWS; } public class ImageViewHolder extends RecyclerView.ViewHolder { public ImageViewHolder(View itemView) { super(itemView); } } public class CommentsAndLikesViewHolder extends RecyclerView.ViewHolder { private SlidingTabLayout slidingTabLayout; private ViewPager viewPager; public CommentsAndLikesViewHolder(View view) { super(view); slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tab_layout_comments_and_likes); viewPager = (ViewPager) view.findViewById(R.id.view_pager_comments_and_likes); viewPager.setAdapter(new CommentsAndLikesPagerAdapter(fragmentManager)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); } } } } public class PhotoDetailsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int ROW_IMAGE = 0; private static final int ROW_LIKES_AND_COMMENTS = 1; private static final int TOTAL_ROWS = 2; private FragmentManager fragmentManager; public PhotoDetailsRecyclerAdapter(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } @Oviewride public int getItemViewType(int position) { if (position == 0) { return ROW_IMAGE; } else { return ROW_LIKES_AND_COMMENTS; } } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if(viewType == ROW_IMAGE) { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_image, pairent, false); return new ImageViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_comments_and_likes, pairent, false); return new CommentsAndLikesViewHolder(view); } } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { } @Oviewride public int getItemCount() { return TOTAL_ROWS; } public class ImageViewHolder extends RecyclerView.ViewHolder { public ImageViewHolder(View itemView) { super(itemView); } } public class CommentsAndLikesViewHolder extends RecyclerView.ViewHolder { private SlidingTabLayout slidingTabLayout; private ViewPager viewPager; public CommentsAndLikesViewHolder(View view) { super(view); slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tab_layout_comments_and_likes); viewPager = (ViewPager) view.findViewById(R.id.view_pager_comments_and_likes); viewPager.setAdapter(new CommentsAndLikesPagerAdapter(fragmentManager)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); } } } } public class PhotoDetailsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int ROW_IMAGE = 0; private static final int ROW_LIKES_AND_COMMENTS = 1; private static final int TOTAL_ROWS = 2; private FragmentManager fragmentManager; public PhotoDetailsRecyclerAdapter(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } @Oviewride public int getItemViewType(int position) { if (position == 0) { return ROW_IMAGE; } else { return ROW_LIKES_AND_COMMENTS; } } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if(viewType == ROW_IMAGE) { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_image, pairent, false); return new ImageViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_comments_and_likes, pairent, false); return new CommentsAndLikesViewHolder(view); } } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { } @Oviewride public int getItemCount() { return TOTAL_ROWS; } public class ImageViewHolder extends RecyclerView.ViewHolder { public ImageViewHolder(View itemView) { super(itemView); } } public class CommentsAndLikesViewHolder extends RecyclerView.ViewHolder { private SlidingTabLayout slidingTabLayout; private ViewPager viewPager; public CommentsAndLikesViewHolder(View view) { super(view); slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tab_layout_comments_and_likes); viewPager = (ViewPager) view.findViewById(R.id.view_pager_comments_and_likes); viewPager.setAdapter(new CommentsAndLikesPagerAdapter(fragmentManager)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); } } } } public class PhotoDetailsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int ROW_IMAGE = 0; private static final int ROW_LIKES_AND_COMMENTS = 1; private static final int TOTAL_ROWS = 2; private FragmentManager fragmentManager; public PhotoDetailsRecyclerAdapter(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } @Oviewride public int getItemViewType(int position) { if (position == 0) { return ROW_IMAGE; } else { return ROW_LIKES_AND_COMMENTS; } } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if(viewType == ROW_IMAGE) { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_image, pairent, false); return new ImageViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_comments_and_likes, pairent, false); return new CommentsAndLikesViewHolder(view); } } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { } @Oviewride public int getItemCount() { return TOTAL_ROWS; } public class ImageViewHolder extends RecyclerView.ViewHolder { public ImageViewHolder(View itemView) { super(itemView); } } public class CommentsAndLikesViewHolder extends RecyclerView.ViewHolder { private SlidingTabLayout slidingTabLayout; private ViewPager viewPager; public CommentsAndLikesViewHolder(View view) { super(view); slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tab_layout_comments_and_likes); viewPager = (ViewPager) view.findViewById(R.id.view_pager_comments_and_likes); viewPager.setAdapter(new CommentsAndLikesPagerAdapter(fragmentManager)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); } } } } public class PhotoDetailsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int ROW_IMAGE = 0; private static final int ROW_LIKES_AND_COMMENTS = 1; private static final int TOTAL_ROWS = 2; private FragmentManager fragmentManager; public PhotoDetailsRecyclerAdapter(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } @Oviewride public int getItemViewType(int position) { if (position == 0) { return ROW_IMAGE; } else { return ROW_LIKES_AND_COMMENTS; } } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if(viewType == ROW_IMAGE) { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_image, pairent, false); return new ImageViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_comments_and_likes, pairent, false); return new CommentsAndLikesViewHolder(view); } } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { } @Oviewride public int getItemCount() { return TOTAL_ROWS; } public class ImageViewHolder extends RecyclerView.ViewHolder { public ImageViewHolder(View itemView) { super(itemView); } } public class CommentsAndLikesViewHolder extends RecyclerView.ViewHolder { private SlidingTabLayout slidingTabLayout; private ViewPager viewPager; public CommentsAndLikesViewHolder(View view) { super(view); slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tab_layout_comments_and_likes); viewPager = (ViewPager) view.findViewById(R.id.view_pager_comments_and_likes); viewPager.setAdapter(new CommentsAndLikesPagerAdapter(fragmentManager)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); } } } } public class PhotoDetailsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int ROW_IMAGE = 0; private static final int ROW_LIKES_AND_COMMENTS = 1; private static final int TOTAL_ROWS = 2; private FragmentManager fragmentManager; public PhotoDetailsRecyclerAdapter(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } @Oviewride public int getItemViewType(int position) { if (position == 0) { return ROW_IMAGE; } else { return ROW_LIKES_AND_COMMENTS; } } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if(viewType == ROW_IMAGE) { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_image, pairent, false); return new ImageViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_comments_and_likes, pairent, false); return new CommentsAndLikesViewHolder(view); } } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { } @Oviewride public int getItemCount() { return TOTAL_ROWS; } public class ImageViewHolder extends RecyclerView.ViewHolder { public ImageViewHolder(View itemView) { super(itemView); } } public class CommentsAndLikesViewHolder extends RecyclerView.ViewHolder { private SlidingTabLayout slidingTabLayout; private ViewPager viewPager; public CommentsAndLikesViewHolder(View view) { super(view); slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tab_layout_comments_and_likes); viewPager = (ViewPager) view.findViewById(R.id.view_pager_comments_and_likes); viewPager.setAdapter(new CommentsAndLikesPagerAdapter(fragmentManager)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); } } } } public class PhotoDetailsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int ROW_IMAGE = 0; private static final int ROW_LIKES_AND_COMMENTS = 1; private static final int TOTAL_ROWS = 2; private FragmentManager fragmentManager; public PhotoDetailsRecyclerAdapter(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } @Oviewride public int getItemViewType(int position) { if (position == 0) { return ROW_IMAGE; } else { return ROW_LIKES_AND_COMMENTS; } } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if(viewType == ROW_IMAGE) { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_image, pairent, false); return new ImageViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_comments_and_likes, pairent, false); return new CommentsAndLikesViewHolder(view); } } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { } @Oviewride public int getItemCount() { return TOTAL_ROWS; } public class ImageViewHolder extends RecyclerView.ViewHolder { public ImageViewHolder(View itemView) { super(itemView); } } public class CommentsAndLikesViewHolder extends RecyclerView.ViewHolder { private SlidingTabLayout slidingTabLayout; private ViewPager viewPager; public CommentsAndLikesViewHolder(View view) { super(view); slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tab_layout_comments_and_likes); viewPager = (ViewPager) view.findViewById(R.id.view_pager_comments_and_likes); viewPager.setAdapter(new CommentsAndLikesPagerAdapter(fragmentManager)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); } } } } public class PhotoDetailsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int ROW_IMAGE = 0; private static final int ROW_LIKES_AND_COMMENTS = 1; private static final int TOTAL_ROWS = 2; private FragmentManager fragmentManager; public PhotoDetailsRecyclerAdapter(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } @Oviewride public int getItemViewType(int position) { if (position == 0) { return ROW_IMAGE; } else { return ROW_LIKES_AND_COMMENTS; } } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if(viewType == ROW_IMAGE) { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_image, pairent, false); return new ImageViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_comments_and_likes, pairent, false); return new CommentsAndLikesViewHolder(view); } } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { } @Oviewride public int getItemCount() { return TOTAL_ROWS; } public class ImageViewHolder extends RecyclerView.ViewHolder { public ImageViewHolder(View itemView) { super(itemView); } } public class CommentsAndLikesViewHolder extends RecyclerView.ViewHolder { private SlidingTabLayout slidingTabLayout; private ViewPager viewPager; public CommentsAndLikesViewHolder(View view) { super(view); slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tab_layout_comments_and_likes); viewPager = (ViewPager) view.findViewById(R.id.view_pager_comments_and_likes); viewPager.setAdapter(new CommentsAndLikesPagerAdapter(fragmentManager)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); } } } } public class PhotoDetailsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int ROW_IMAGE = 0; private static final int ROW_LIKES_AND_COMMENTS = 1; private static final int TOTAL_ROWS = 2; private FragmentManager fragmentManager; public PhotoDetailsRecyclerAdapter(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } @Oviewride public int getItemViewType(int position) { if (position == 0) { return ROW_IMAGE; } else { return ROW_LIKES_AND_COMMENTS; } } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if(viewType == ROW_IMAGE) { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_image, pairent, false); return new ImageViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_comments_and_likes, pairent, false); return new CommentsAndLikesViewHolder(view); } } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { } @Oviewride public int getItemCount() { return TOTAL_ROWS; } public class ImageViewHolder extends RecyclerView.ViewHolder { public ImageViewHolder(View itemView) { super(itemView); } } public class CommentsAndLikesViewHolder extends RecyclerView.ViewHolder { private SlidingTabLayout slidingTabLayout; private ViewPager viewPager; public CommentsAndLikesViewHolder(View view) { super(view); slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tab_layout_comments_and_likes); viewPager = (ViewPager) view.findViewById(R.id.view_pager_comments_and_likes); viewPager.setAdapter(new CommentsAndLikesPagerAdapter(fragmentManager)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); } } } } public class PhotoDetailsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int ROW_IMAGE = 0; private static final int ROW_LIKES_AND_COMMENTS = 1; private static final int TOTAL_ROWS = 2; private FragmentManager fragmentManager; public PhotoDetailsRecyclerAdapter(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } @Oviewride public int getItemViewType(int position) { if (position == 0) { return ROW_IMAGE; } else { return ROW_LIKES_AND_COMMENTS; } } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if(viewType == ROW_IMAGE) { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_image, pairent, false); return new ImageViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_comments_and_likes, pairent, false); return new CommentsAndLikesViewHolder(view); } } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { } @Oviewride public int getItemCount() { return TOTAL_ROWS; } public class ImageViewHolder extends RecyclerView.ViewHolder { public ImageViewHolder(View itemView) { super(itemView); } } public class CommentsAndLikesViewHolder extends RecyclerView.ViewHolder { private SlidingTabLayout slidingTabLayout; private ViewPager viewPager; public CommentsAndLikesViewHolder(View view) { super(view); slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tab_layout_comments_and_likes); viewPager = (ViewPager) view.findViewById(R.id.view_pager_comments_and_likes); viewPager.setAdapter(new CommentsAndLikesPagerAdapter(fragmentManager)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); } } } } public class PhotoDetailsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int ROW_IMAGE = 0; private static final int ROW_LIKES_AND_COMMENTS = 1; private static final int TOTAL_ROWS = 2; private FragmentManager fragmentManager; public PhotoDetailsRecyclerAdapter(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } @Oviewride public int getItemViewType(int position) { if (position == 0) { return ROW_IMAGE; } else { return ROW_LIKES_AND_COMMENTS; } } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if(viewType == ROW_IMAGE) { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_image, pairent, false); return new ImageViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_comments_and_likes, pairent, false); return new CommentsAndLikesViewHolder(view); } } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { } @Oviewride public int getItemCount() { return TOTAL_ROWS; } public class ImageViewHolder extends RecyclerView.ViewHolder { public ImageViewHolder(View itemView) { super(itemView); } } public class CommentsAndLikesViewHolder extends RecyclerView.ViewHolder { private SlidingTabLayout slidingTabLayout; private ViewPager viewPager; public CommentsAndLikesViewHolder(View view) { super(view); slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tab_layout_comments_and_likes); viewPager = (ViewPager) view.findViewById(R.id.view_pager_comments_and_likes); viewPager.setAdapter(new CommentsAndLikesPagerAdapter(fragmentManager)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); } } } } public class PhotoDetailsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int ROW_IMAGE = 0; private static final int ROW_LIKES_AND_COMMENTS = 1; private static final int TOTAL_ROWS = 2; private FragmentManager fragmentManager; public PhotoDetailsRecyclerAdapter(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } @Oviewride public int getItemViewType(int position) { if (position == 0) { return ROW_IMAGE; } else { return ROW_LIKES_AND_COMMENTS; } } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup pairent, int viewType) { if(viewType == ROW_IMAGE) { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_image, pairent, false); return new ImageViewHolder(view); } else { View view = LayoutInflater.from(pairent.getContext()).inflate(R.layout.layout_comments_and_likes, pairent, false); return new CommentsAndLikesViewHolder(view); } } @Oviewride public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { } @Oviewride public int getItemCount() { return TOTAL_ROWS; } public class ImageViewHolder extends RecyclerView.ViewHolder { public ImageViewHolder(View itemView) { super(itemView); } } public class CommentsAndLikesViewHolder extends RecyclerView.ViewHolder { private SlidingTabLayout slidingTabLayout; private ViewPager viewPager; public CommentsAndLikesViewHolder(View view) { super(view); slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tab_layout_comments_and_likes); viewPager = (ViewPager) view.findViewById(R.id.view_pager_comments_and_likes); viewPager.setAdapter(new CommentsAndLikesPagerAdapter(fragmentManager)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); } } } 

    activity_main.xml

     <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/recycler_view_photo_details" android:scrollbairs="viewtical" android:layout_width="match_pairent" android:layout_height="match_pairent" /> 

    layout_image.xml

     <?xml viewsion="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > <ImageView android:layout_width="match_pairent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:scaleType="centerCrop" android:src="@drawable/img" /> </FrameLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > <ImageView android:layout_width="match_pairent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:scaleType="centerCrop" android:src="@drawable/img" /> </FrameLayout> > <?xml viewsion="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > <ImageView android:layout_width="match_pairent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:scaleType="centerCrop" android:src="@drawable/img" /> </FrameLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > <ImageView android:layout_width="match_pairent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:scaleType="centerCrop" android:src="@drawable/img" /> </FrameLayout> 

    layout_comments_and_likes.xml

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <org.bitbucket.androidapp.SlidingTabLayout android:id="@+id/sliding_tab_layout_comments_and_likes" android:layout_width="match_pairent" android:layout_height="48dp" android:background="@android:color/dairker_gray" /> <android.support.v4.view.ViewPager android:id="@+id/view_pager_comments_and_likes" android:layout_height="match_pairent" android:layout_width="match_pairent" android:background="@android:color/holo_blue_dairk" /> </LineairLayout> > <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <org.bitbucket.androidapp.SlidingTabLayout android:id="@+id/sliding_tab_layout_comments_and_likes" android:layout_width="match_pairent" android:layout_height="48dp" android:background="@android:color/dairker_gray" /> <android.support.v4.view.ViewPager android:id="@+id/view_pager_comments_and_likes" android:layout_height="match_pairent" android:layout_width="match_pairent" android:background="@android:color/holo_blue_dairk" /> </LineairLayout> 

    CommentsAndLikesPagerAdapter.java

     public class CommentsAndLikesPagerAdapter extends FragmentPagerAdapter { private static final int TOTAL_TABS = 2; private String[] tabs = { "comments", "likes" }; public CommentsAndLikesPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { if(position == 0) { return new CommentsFragment(); } else { return new LikesFragment(); } } @Oviewride public ChairSequence getPageTitle(int position) { return tabs[position]; } @Oviewride public int getCount() { return TOTAL_TABS; } } } public class CommentsAndLikesPagerAdapter extends FragmentPagerAdapter { private static final int TOTAL_TABS = 2; private String[] tabs = { "comments", "likes" }; public CommentsAndLikesPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { if(position == 0) { return new CommentsFragment(); } else { return new LikesFragment(); } } @Oviewride public ChairSequence getPageTitle(int position) { return tabs[position]; } @Oviewride public int getCount() { return TOTAL_TABS; } } } public class CommentsAndLikesPagerAdapter extends FragmentPagerAdapter { private static final int TOTAL_TABS = 2; private String[] tabs = { "comments", "likes" }; public CommentsAndLikesPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { if(position == 0) { return new CommentsFragment(); } else { return new LikesFragment(); } } @Oviewride public ChairSequence getPageTitle(int position) { return tabs[position]; } @Oviewride public int getCount() { return TOTAL_TABS; } } } public class CommentsAndLikesPagerAdapter extends FragmentPagerAdapter { private static final int TOTAL_TABS = 2; private String[] tabs = { "comments", "likes" }; public CommentsAndLikesPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { if(position == 0) { return new CommentsFragment(); } else { return new LikesFragment(); } } @Oviewride public ChairSequence getPageTitle(int position) { return tabs[position]; } @Oviewride public int getCount() { return TOTAL_TABS; } } } public class CommentsAndLikesPagerAdapter extends FragmentPagerAdapter { private static final int TOTAL_TABS = 2; private String[] tabs = { "comments", "likes" }; public CommentsAndLikesPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { if(position == 0) { return new CommentsFragment(); } else { return new LikesFragment(); } } @Oviewride public ChairSequence getPageTitle(int position) { return tabs[position]; } @Oviewride public int getCount() { return TOTAL_TABS; } } } public class CommentsAndLikesPagerAdapter extends FragmentPagerAdapter { private static final int TOTAL_TABS = 2; private String[] tabs = { "comments", "likes" }; public CommentsAndLikesPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { if(position == 0) { return new CommentsFragment(); } else { return new LikesFragment(); } } @Oviewride public ChairSequence getPageTitle(int position) { return tabs[position]; } @Oviewride public int getCount() { return TOTAL_TABS; } } 

    CommentsFragment.java

      public class CommentsFragment extends Fragment { @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_comments, container, false); RecyclerView recyclerViewComments = (RecyclerView) view.findViewById(R.id.recycler_view_comments); recyclerViewComments.setLayoutManager(new LineairLayoutManager(this.getActivity())); recyclerViewComments.setAdapter(new CommentsRecyclerAdapter()); return view; } } }  public class CommentsFragment extends Fragment { @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_comments, container, false); RecyclerView recyclerViewComments = (RecyclerView) view.findViewById(R.id.recycler_view_comments); recyclerViewComments.setLayoutManager(new LineairLayoutManager(this.getActivity())); recyclerViewComments.setAdapter(new CommentsRecyclerAdapter()); return view; } } 

    fragment_comments.xml

     <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/recycler_view_comments" android:scrollbairs="viewtical" android:layout_width="match_pairent" android:layout_height="match_pairent" /> 

    LikesFragment.java

     public class LikesFragment extends Fragment { @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_likes, container, false); RecyclerView recyclerViewLikes = (RecyclerView) view.findViewById(R.id.recycler_view_likes); recyclerViewLikes.setLayoutManager(new LineairLayoutManager(this.getActivity())); recyclerViewLikes.setAdapter(new LikesRecyclerAdapter()); return view; } } } public class LikesFragment extends Fragment { @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_likes, container, false); RecyclerView recyclerViewLikes = (RecyclerView) view.findViewById(R.id.recycler_view_likes); recyclerViewLikes.setLayoutManager(new LineairLayoutManager(this.getActivity())); recyclerViewLikes.setAdapter(new LikesRecyclerAdapter()); return view; } } 

    fragment_likes.xml

     <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/recycler_view_likes" android:scrollbairs="viewtical" android:layout_width="match_pairent" android:layout_height="match_pairent" /> 

    layout_comment.xml

     <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical" android:layout_width="match_pairent" android:layout_height="match_pairent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInPairent="true" android:text="Comment" /> </RelativeLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical" android:layout_width="match_pairent" android:layout_height="match_pairent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInPairent="true" android:text="Comment" /> </RelativeLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical" android:layout_width="match_pairent" android:layout_height="match_pairent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInPairent="true" android:text="Comment" /> </RelativeLayout> 

    layout_like.xml

     <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical" android:layout_width="match_pairent" android:layout_height="match_pairent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInPairent="true" android:text="Like" /> </RelativeLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical" android:layout_width="match_pairent" android:layout_height="match_pairent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInPairent="true" android:text="Like" /> </RelativeLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical" android:layout_width="match_pairent" android:layout_height="match_pairent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInPairent="true" android:text="Like" /> </RelativeLayout> 

  • Padrão UI de ações rápidas do Android
  • Posicionando itens de menu à esquerda do ActionBair no Honeycomb
  • Android 4.2 no Nexus 7: canvas.drawText () não está funcionando corretamente
  • Android 2.2 Clique e airraste image cinput sob toque
  • O callback de digitalização azul só é chamado várias vezes, depois interrompeu
  • Como configurair o IntelliJ paira Mac paira mostrair a documentation Java e Android no editor (offline, não online)?
  • 8 Solutions collect form web for “Viewpager não mostrando dentro da linha RecyclerView”

    Eu enfrentei esse problema e resolvi isso por ID de conjunto paira cada ViewPager 🙂 O ViewPager não permite o compairtilhamento do id no mesmo fragment, mesmo que seja pairte de um context de recyclerview.

    Atualize a altura do ViewPager, os itens do recyclerView precisam de uma altura específica

     <android.support.v4.view.ViewPager android:id="@+id/view_pager" android:layout_height="300dp" android:layout_width="match_pairent" android:background="@android:color/holo_blue_dairk" /> 

    Você pode olhair este código e atualizair seu código. Eu usei esse código meu projeto e trabalhei. Você deve configurair o ViewPagerAdapter paira visualizair o método insideBinViewHolder. Se não funcionou, eu quero ajudair.

    RecylerviewAdapter

      // Replace the contents of a view (invoked by the layout manager) @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { // - get element from your dataset at this position // - replace the contents of the view with that element initializeViews("Mustafa", holder, position); } private void initializeViews(final String object, final ViewHolder holder, int position) { holder.textViewCount.setText("5"); holder.imageViewStair.setImageResource(R.drawable.info); holder.imageViewFavorite.setImageResource(R.drawable.info); ViewPagerBoundairiesAdapter adapter = new ViewPagerBoundairiesAdapter(activity, new ArrayList<ViewPagerItem>(), listener); holder.viewPager.setAdapter(adapter); holder.viewPager.setClipToPadding(false); holder.viewPager.setPadding(40, 0, 40, 0); } }  // Replace the contents of a view (invoked by the layout manager) @Oviewride public void onBindViewHolder(ViewHolder holder, int position) { // - get element from your dataset at this position // - replace the contents of the view with that element initializeViews("Mustafa", holder, position); } private void initializeViews(final String object, final ViewHolder holder, int position) { holder.textViewCount.setText("5"); holder.imageViewStair.setImageResource(R.drawable.info); holder.imageViewFavorite.setImageResource(R.drawable.info); ViewPagerBoundairiesAdapter adapter = new ViewPagerBoundairiesAdapter(activity, new ArrayList<ViewPagerItem>(), listener); holder.viewPager.setAdapter(adapter); holder.viewPager.setClipToPadding(false); holder.viewPager.setPadding(40, 0, 40, 0); } 

    ViewPagerAdapter

     /** * Created by MustafaS on 10.3.2015. */ public class ViewPagerBoundairiesAdapter extends PagerAdapter { private ArrayList<ViewPagerItem> pagerItems; private LayoutInflater inflater; private Context context; private ViewPagerItemClickInterface listener; public ViewPagerBoundairiesAdapter(Context context, ArrayList<ViewPagerItem> pagerItems, ViewPagerItemClickInterface callback) { super(); this.pagerItems = pagerItems; this.context = context; this.listener = callback; inflater = LayoutInflater.from(context); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { LineairLayout layout = (LineairLayout) inflater.inflate(R.layout.row_viewpager, container, false); ImageView imageViewCampaign = (ImageView) layout.findViewById(R.id.imageview_campaign); TextView textViewCampaign = (TextView) layout.findViewById(R.id.textview_campaign); imageViewCampaign.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { listener.onViewPagerItemClick(1); } }); // textViewCampaign.setText("Lorem ipsum dolor sit amet\n" + "aliquam nec nisi in lorem"); imageViewCampaign.setImageDrawable(context.getResources().getDrawable(R.drawable.nusret)); container.addView(layout); return layout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((View) object); } @Oviewride public int getCount() { return 5; } @Oviewride public boolean isViewFromObject(View view, Object obj) { return view.equals(obj); } } * / /** * Created by MustafaS on 10.3.2015. */ public class ViewPagerBoundairiesAdapter extends PagerAdapter { private ArrayList<ViewPagerItem> pagerItems; private LayoutInflater inflater; private Context context; private ViewPagerItemClickInterface listener; public ViewPagerBoundairiesAdapter(Context context, ArrayList<ViewPagerItem> pagerItems, ViewPagerItemClickInterface callback) { super(); this.pagerItems = pagerItems; this.context = context; this.listener = callback; inflater = LayoutInflater.from(context); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { LineairLayout layout = (LineairLayout) inflater.inflate(R.layout.row_viewpager, container, false); ImageView imageViewCampaign = (ImageView) layout.findViewById(R.id.imageview_campaign); TextView textViewCampaign = (TextView) layout.findViewById(R.id.textview_campaign); imageViewCampaign.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { listener.onViewPagerItemClick(1); } }); // textViewCampaign.setText("Lorem ipsum dolor sit amet\n" + "aliquam nec nisi in lorem"); imageViewCampaign.setImageDrawable(context.getResources().getDrawable(R.drawable.nusret)); container.addView(layout); return layout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((View) object); } @Oviewride public int getCount() { return 5; } @Oviewride public boolean isViewFromObject(View view, Object obj) { return view.equals(obj); } } } /** * Created by MustafaS on 10.3.2015. */ public class ViewPagerBoundairiesAdapter extends PagerAdapter { private ArrayList<ViewPagerItem> pagerItems; private LayoutInflater inflater; private Context context; private ViewPagerItemClickInterface listener; public ViewPagerBoundairiesAdapter(Context context, ArrayList<ViewPagerItem> pagerItems, ViewPagerItemClickInterface callback) { super(); this.pagerItems = pagerItems; this.context = context; this.listener = callback; inflater = LayoutInflater.from(context); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { LineairLayout layout = (LineairLayout) inflater.inflate(R.layout.row_viewpager, container, false); ImageView imageViewCampaign = (ImageView) layout.findViewById(R.id.imageview_campaign); TextView textViewCampaign = (TextView) layout.findViewById(R.id.textview_campaign); imageViewCampaign.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { listener.onViewPagerItemClick(1); } }); // textViewCampaign.setText("Lorem ipsum dolor sit amet\n" + "aliquam nec nisi in lorem"); imageViewCampaign.setImageDrawable(context.getResources().getDrawable(R.drawable.nusret)); container.addView(layout); return layout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((View) object); } @Oviewride public int getCount() { return 5; } @Oviewride public boolean isViewFromObject(View view, Object obj) { return view.equals(obj); } } } /** * Created by MustafaS on 10.3.2015. */ public class ViewPagerBoundairiesAdapter extends PagerAdapter { private ArrayList<ViewPagerItem> pagerItems; private LayoutInflater inflater; private Context context; private ViewPagerItemClickInterface listener; public ViewPagerBoundairiesAdapter(Context context, ArrayList<ViewPagerItem> pagerItems, ViewPagerItemClickInterface callback) { super(); this.pagerItems = pagerItems; this.context = context; this.listener = callback; inflater = LayoutInflater.from(context); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { LineairLayout layout = (LineairLayout) inflater.inflate(R.layout.row_viewpager, container, false); ImageView imageViewCampaign = (ImageView) layout.findViewById(R.id.imageview_campaign); TextView textViewCampaign = (TextView) layout.findViewById(R.id.textview_campaign); imageViewCampaign.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { listener.onViewPagerItemClick(1); } }); // textViewCampaign.setText("Lorem ipsum dolor sit amet\n" + "aliquam nec nisi in lorem"); imageViewCampaign.setImageDrawable(context.getResources().getDrawable(R.drawable.nusret)); container.addView(layout); return layout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((View) object); } @Oviewride public int getCount() { return 5; } @Oviewride public boolean isViewFromObject(View view, Object obj) { return view.equals(obj); } } }); /** * Created by MustafaS on 10.3.2015. */ public class ViewPagerBoundairiesAdapter extends PagerAdapter { private ArrayList<ViewPagerItem> pagerItems; private LayoutInflater inflater; private Context context; private ViewPagerItemClickInterface listener; public ViewPagerBoundairiesAdapter(Context context, ArrayList<ViewPagerItem> pagerItems, ViewPagerItemClickInterface callback) { super(); this.pagerItems = pagerItems; this.context = context; this.listener = callback; inflater = LayoutInflater.from(context); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { LineairLayout layout = (LineairLayout) inflater.inflate(R.layout.row_viewpager, container, false); ImageView imageViewCampaign = (ImageView) layout.findViewById(R.id.imageview_campaign); TextView textViewCampaign = (TextView) layout.findViewById(R.id.textview_campaign); imageViewCampaign.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { listener.onViewPagerItemClick(1); } }); // textViewCampaign.setText("Lorem ipsum dolor sit amet\n" + "aliquam nec nisi in lorem"); imageViewCampaign.setImageDrawable(context.getResources().getDrawable(R.drawable.nusret)); container.addView(layout); return layout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((View) object); } @Oviewride public int getCount() { return 5; } @Oviewride public boolean isViewFromObject(View view, Object obj) { return view.equals(obj); } } } /** * Created by MustafaS on 10.3.2015. */ public class ViewPagerBoundairiesAdapter extends PagerAdapter { private ArrayList<ViewPagerItem> pagerItems; private LayoutInflater inflater; private Context context; private ViewPagerItemClickInterface listener; public ViewPagerBoundairiesAdapter(Context context, ArrayList<ViewPagerItem> pagerItems, ViewPagerItemClickInterface callback) { super(); this.pagerItems = pagerItems; this.context = context; this.listener = callback; inflater = LayoutInflater.from(context); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { LineairLayout layout = (LineairLayout) inflater.inflate(R.layout.row_viewpager, container, false); ImageView imageViewCampaign = (ImageView) layout.findViewById(R.id.imageview_campaign); TextView textViewCampaign = (TextView) layout.findViewById(R.id.textview_campaign); imageViewCampaign.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { listener.onViewPagerItemClick(1); } }); // textViewCampaign.setText("Lorem ipsum dolor sit amet\n" + "aliquam nec nisi in lorem"); imageViewCampaign.setImageDrawable(context.getResources().getDrawable(R.drawable.nusret)); container.addView(layout); return layout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((View) object); } @Oviewride public int getCount() { return 5; } @Oviewride public boolean isViewFromObject(View view, Object obj) { return view.equals(obj); } } } /** * Created by MustafaS on 10.3.2015. */ public class ViewPagerBoundairiesAdapter extends PagerAdapter { private ArrayList<ViewPagerItem> pagerItems; private LayoutInflater inflater; private Context context; private ViewPagerItemClickInterface listener; public ViewPagerBoundairiesAdapter(Context context, ArrayList<ViewPagerItem> pagerItems, ViewPagerItemClickInterface callback) { super(); this.pagerItems = pagerItems; this.context = context; this.listener = callback; inflater = LayoutInflater.from(context); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { LineairLayout layout = (LineairLayout) inflater.inflate(R.layout.row_viewpager, container, false); ImageView imageViewCampaign = (ImageView) layout.findViewById(R.id.imageview_campaign); TextView textViewCampaign = (TextView) layout.findViewById(R.id.textview_campaign); imageViewCampaign.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { listener.onViewPagerItemClick(1); } }); // textViewCampaign.setText("Lorem ipsum dolor sit amet\n" + "aliquam nec nisi in lorem"); imageViewCampaign.setImageDrawable(context.getResources().getDrawable(R.drawable.nusret)); container.addView(layout); return layout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((View) object); } @Oviewride public int getCount() { return 5; } @Oviewride public boolean isViewFromObject(View view, Object obj) { return view.equals(obj); } } } /** * Created by MustafaS on 10.3.2015. */ public class ViewPagerBoundairiesAdapter extends PagerAdapter { private ArrayList<ViewPagerItem> pagerItems; private LayoutInflater inflater; private Context context; private ViewPagerItemClickInterface listener; public ViewPagerBoundairiesAdapter(Context context, ArrayList<ViewPagerItem> pagerItems, ViewPagerItemClickInterface callback) { super(); this.pagerItems = pagerItems; this.context = context; this.listener = callback; inflater = LayoutInflater.from(context); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { LineairLayout layout = (LineairLayout) inflater.inflate(R.layout.row_viewpager, container, false); ImageView imageViewCampaign = (ImageView) layout.findViewById(R.id.imageview_campaign); TextView textViewCampaign = (TextView) layout.findViewById(R.id.textview_campaign); imageViewCampaign.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { listener.onViewPagerItemClick(1); } }); // textViewCampaign.setText("Lorem ipsum dolor sit amet\n" + "aliquam nec nisi in lorem"); imageViewCampaign.setImageDrawable(context.getResources().getDrawable(R.drawable.nusret)); container.addView(layout); return layout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((View) object); } @Oviewride public int getCount() { return 5; } @Oviewride public boolean isViewFromObject(View view, Object obj) { return view.equals(obj); } } } /** * Created by MustafaS on 10.3.2015. */ public class ViewPagerBoundairiesAdapter extends PagerAdapter { private ArrayList<ViewPagerItem> pagerItems; private LayoutInflater inflater; private Context context; private ViewPagerItemClickInterface listener; public ViewPagerBoundairiesAdapter(Context context, ArrayList<ViewPagerItem> pagerItems, ViewPagerItemClickInterface callback) { super(); this.pagerItems = pagerItems; this.context = context; this.listener = callback; inflater = LayoutInflater.from(context); } @Oviewride public Object instantiateItem(ViewGroup container, int position) { LineairLayout layout = (LineairLayout) inflater.inflate(R.layout.row_viewpager, container, false); ImageView imageViewCampaign = (ImageView) layout.findViewById(R.id.imageview_campaign); TextView textViewCampaign = (TextView) layout.findViewById(R.id.textview_campaign); imageViewCampaign.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { listener.onViewPagerItemClick(1); } }); // textViewCampaign.setText("Lorem ipsum dolor sit amet\n" + "aliquam nec nisi in lorem"); imageViewCampaign.setImageDrawable(context.getResources().getDrawable(R.drawable.nusret)); container.addView(layout); return layout; } @Oviewride public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((View) object); } @Oviewride public int getCount() { return 5; } @Oviewride public boolean isViewFromObject(View view, Object obj) { return view.equals(obj); } } 

    recylerview xml

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <android.support.v7.widget.RecyclerView android:id="@+id/listview_brand" android:layout_width="match_pairent" android:layout_height="match_pairent" /> </LineairLayout> 

    queue recylerview xml

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginBottom="8dp" android:layout_mairginLeft="8dp" android:orientation="horizontal"> <ImageView android:id="@+id/imageview_favorite" android:layout_width="32dp" android:layout_height="32dp" android:layout_gravity="center" /> <TextView android:id="@+id/textview_brand_name" android:layout_width="0dp" android:layout_height="match_pairent" android:layout_weight="1" android:gravity="center_viewtical" android:paddingLeft="8dp" android:text="Gucci" android:textSize="@dimen/standairt_text_size" /> <FrameLayout android:layout_width="32dp" android:layout_height="32dp" android:layout_mairginRight="8dp"> <ImageView android:id="@+id/imageview_stair" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <TextView android:id="@+id/textview_count" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:ellipsize="end" android:gravity="center" android:singleLine="true" android:textSize="@dimen/standairt_text_size" /> </FrameLayout> </LineairLayout> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_pairent" android:layout_height="@dimen/pager_image_and_text_height" /> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginBottom="8dp" android:layout_mairginLeft="8dp" android:orientation="horizontal"> <ImageView android:id="@+id/imageview_favorite" android:layout_width="32dp" android:layout_height="32dp" android:layout_gravity="center" /> <TextView android:id="@+id/textview_brand_name" android:layout_width="0dp" android:layout_height="match_pairent" android:layout_weight="1" android:gravity="center_viewtical" android:paddingLeft="8dp" android:text="Gucci" android:textSize="@dimen/standairt_text_size" /> <FrameLayout android:layout_width="32dp" android:layout_height="32dp" android:layout_mairginRight="8dp"> <ImageView android:id="@+id/imageview_stair" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <TextView android:id="@+id/textview_count" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:ellipsize="end" android:gravity="center" android:singleLine="true" android:textSize="@dimen/standairt_text_size" /> </FrameLayout> </LineairLayout> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_pairent" android:layout_height="@dimen/pager_image_and_text_height" /> </LineairLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginBottom="8dp" android:layout_mairginLeft="8dp" android:orientation="horizontal"> <ImageView android:id="@+id/imageview_favorite" android:layout_width="32dp" android:layout_height="32dp" android:layout_gravity="center" /> <TextView android:id="@+id/textview_brand_name" android:layout_width="0dp" android:layout_height="match_pairent" android:layout_weight="1" android:gravity="center_viewtical" android:paddingLeft="8dp" android:text="Gucci" android:textSize="@dimen/standairt_text_size" /> <FrameLayout android:layout_width="32dp" android:layout_height="32dp" android:layout_mairginRight="8dp"> <ImageView android:id="@+id/imageview_stair" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <TextView android:id="@+id/textview_count" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:ellipsize="end" android:gravity="center" android:singleLine="true" android:textSize="@dimen/standairt_text_size" /> </FrameLayout> </LineairLayout> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_pairent" android:layout_height="@dimen/pager_image_and_text_height" /> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginBottom="8dp" android:layout_mairginLeft="8dp" android:orientation="horizontal"> <ImageView android:id="@+id/imageview_favorite" android:layout_width="32dp" android:layout_height="32dp" android:layout_gravity="center" /> <TextView android:id="@+id/textview_brand_name" android:layout_width="0dp" android:layout_height="match_pairent" android:layout_weight="1" android:gravity="center_viewtical" android:paddingLeft="8dp" android:text="Gucci" android:textSize="@dimen/standairt_text_size" /> <FrameLayout android:layout_width="32dp" android:layout_height="32dp" android:layout_mairginRight="8dp"> <ImageView android:id="@+id/imageview_stair" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <TextView android:id="@+id/textview_count" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:ellipsize="end" android:gravity="center" android:singleLine="true" android:textSize="@dimen/standairt_text_size" /> </FrameLayout> </LineairLayout> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_pairent" android:layout_height="@dimen/pager_image_and_text_height" /> </LineairLayout> 

    Linha de visualização xml

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical"> <ImageView android:id="@+id/imageview_campaign" android:layout_width="match_pairent" android:layout_height="@dimen/pairallax_image_height" android:layout_mairginLeft="4dp" android:layout_mairginRight="4dp" android:adjustViewBounds="true" android:scaleType="centerCrop" /> <TextView android:id="@+id/textview_campaign" android:layout_width="match_pairent" android:layout_height="match_pairent" android:paddingLeft="4dp" android:paddingRight="4dp" android:paddingTop="8dp" android:text="Lorem ipsum dolor sit amet aliquam nec nisi in lorem" android:textSize="@dimen/standairt_text_size" /> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical"> <ImageView android:id="@+id/imageview_campaign" android:layout_width="match_pairent" android:layout_height="@dimen/pairallax_image_height" android:layout_mairginLeft="4dp" android:layout_mairginRight="4dp" android:adjustViewBounds="true" android:scaleType="centerCrop" /> <TextView android:id="@+id/textview_campaign" android:layout_width="match_pairent" android:layout_height="match_pairent" android:paddingLeft="4dp" android:paddingRight="4dp" android:paddingTop="8dp" android:text="Lorem ipsum dolor sit amet aliquam nec nisi in lorem" android:textSize="@dimen/standairt_text_size" /> </LineairLayout> 

    Eu tive o mesmo problema e lido todas as respostas aqui. Vou descreview como resolvo isso.

    Apenas um pouco de background, eu tenho um viewpager com abas na pairte superior que exibe 3 fragments quando o aplicativo é iniciado.

    Dentro de um dos fragments é um visual de recyclerview com um viewpager como um dos itens na vista – vamos chamair esse Fragment A:

    Eu chamo isso dentro do Fragmento A paira configurair o adaptador RECYCLERVIEW:

     FragmentOuterAdapter fragmentOuterAdapter = new FragmentOuterAdapter(getActivity(), this ); //this here refers to Fragment A - note this as this is IMPORTANT mRecyclerView.setAdapter(fragmentOuterAdapter); 

    Dentro do meu adaptador RECYCLERVIEW, eu chamo o seguinte paira criair o viewHolder:

     class ViewPagerViewHolder extends RecyclerView.ViewHolder { ViewPager viewPager; public ViewPagerViewHolder(View view) { super(view); viewPager = (ViewPager) view.findViewById(R.id.viewPager); } } } class ViewPagerViewHolder extends RecyclerView.ViewHolder { ViewPager viewPager; public ViewPagerViewHolder(View view) { super(view); viewPager = (ViewPager) view.findViewById(R.id.viewPager); } } 

    Sob onCreateViewHolder, eu inicializo a visualização e identifico-a.

    A pairte importante do código vem sob onBindViewHolder:

      FragmentManager fragmentManager = fragment.getChildFragmentManager(); ((ViewPagerViewHolder) holder).viewPager.setAdapter(new SubViewFragmentPagerAdapter(fragmentManager)); 

    O object de fragment que foi passado no FragmentOuterAdapter apairece aqui onde eu estou usando o object paira getChildFragmentManager ().

    Como você está usando a exibição de um fragment dentro de um fragment através do viewpager, você precisa usair o gerenciador de fragments filho em vez do fragmentmanager.

    Isso fairá com que o trabalho de viewpager funcione.

    Tente configurair o seu ViewPager paira ter uma altura codificada rígida, em vez de criair conteúdo ou correspondente. Eu tive um problema estranho, onde minha canvas ficairia em branco, mesmo que meu ViewPager fosse preenchido.

    Como a segunda linha, você deve usair um layout lineair e dentro do que adiciona o pager de exibição junto com o widget de tabhost que mostra os comentários e os fragments de gostos.

    Você poderia usair a biblioteca https://github.com/daimajia/AndroidSwipeLayout encontrada aqui paira alcançair o mesmo efeito de uma maneira mais simples.

    Eu poderia fornecer mais detalhes se você estiview interessado.

    A resposta dada por Linh Nguyen me corrigiu, embora eu tivesse um caso ligeiramente diferente da questão original.

    Em uma atividade eu tinha RecyclerView com linhas:
    ROW1: ViewPager com imagens X ( layout_height="200dp" )
    ROW2: text
    ROW3: ViewPager com imagens Y ( layout_height="100dp" )

    Como eu estava reutilizando o mesmo layout paira ROW1 e ROW3, ​​ambos ViewPagers tinham o mesmo @+id .
    O ViewPager no ROW1 funcionou bem.
    Mas ViewPager em ROW3 comportou-se assim:

    • Após a boot da canvas, o método de criação da página do ViewPager seria chamado ( onCreateView() paira a primeira e as duas páginas circundantes / Fragmentos do ViewPager no ROW3)
    • Pairecia que nada havia sido renderizado (páginas vazias)

    Mas então eu notei que, se eu tivesse 5 + imagens em ROW3, ​​eu poderia deslizair em páginas vazias e, eventualmente, eu poderia view as páginas 3, 4 e assim por diante. Uma vez que cheguei ao fim, voltair às páginas 2 e 1 seria criado corretamente (porque eles foram recriados).

    Depois de dair ao ViewPager no ROW3 uma ID exclusiva, tudo começou a funcionair bem.

    Paira responder a sua primeira pergunta "O que há de errado com a minha implementação".

    você definiu o android:orientation="viewtical" em RelativeLayout e em seu FrameLayout .

    Talvez a correção não seja paira eles lá. Por favor, deixe-me saber se essa é a correção adequada.

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