Below is the XML code for TabLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.bapji.cubeon.FirstFragment"
android:id="@+id/first"
android:orientation="vertical"
android:background="@color/any">
<!-- TODO: Update blank fragment layout -->
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentBottom="true"
app:tabMode="fixed"
app:tabGravity="fill"
android:background="@color/any"
app:tabSelectedTextColor="@color/white"
app:tabTextColor="@color/white"
app:tabIndicatorColor="@color/white"
android:layout_above="@+id/container"
>
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/any"
android:layout_weight="1"
>
</android.support.v4.view.ViewPager>
</LinearLayout>
Below is the XML code for RecyclerView
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/solve_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
Here I am not able to scroll this RecyclerView while in the TabLayout I am only getting fixed items of that RecyclerView and rest items i am not able to see so if anyone can help me solve this problem will be helpful to me.
Edit - ScreenShot of problem
Below is code for FragmentPagerAdapter
public class SectionPageAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public void addFragment(Fragment fragment, String title){
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}
public SectionPageAdapter(FragmentManager fm) {
super(fm);
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
}
RecyclerViewAdapter java code
public class SolveAdapter extends RecyclerView.Adapter<SolveAdapter.SolveViewHolder> {
Context context;
List<EachTime> mSolves;
public SolveAdapter(Context context, List<EachTime> mSolves) {
this.context = context;
this.mSolves = mSolves;
}
@Nullable
@Override
public SolveViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View layout;
layout = LayoutInflater.from(context).inflate(R.layout.fragment_each_time,parent,false);
return new SolveViewHolder(layout);
}
@Override
public void onBindViewHolder(SolveViewHolder holder, int position) {
holder.eachSolveTime.setText(mSolves.get(position).getCount());
holder.eachSolveScramble.setText(mSolves.get(position).getScramble());
holder.eachSolveDate.setText(mSolves.get(position).getDate());
}
@Override
public int getItemCount() {
return mSolves.size();
}
public class SolveViewHolder extends RecyclerView.ViewHolder{
TextView eachSolveTime,eachSolveDate,eachSolveScramble;
public SolveViewHolder(View itemView) {
super(itemView);
eachSolveDate = itemView.findViewById(R.id.each_solve_date);
eachSolveScramble = itemView.findViewById(R.id.each_solve_scramble);
eachSolveTime = itemView.findViewById(R.id.each_solve_title);
}
}
}
Try to set android:layout_height="0dp" on ViewPager because you use android:layout_weight="1" in your xml code
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/any"
android:layout_weight="1"
/>
Edit --
i think your question is duplicate to this answer