Answer the question
In order to leave comments, you need to log in
How to display Recycler View in bottom sheet?
I need to create a bottom sheet with two views: a horizontal rececler view and a liner layout below it. How to do this if I implement the bottom sheet through the BottomSheetDialogFragment. I tried to declare a recyclerview there, as in normal fragments, but it is not displayed on the device during the test. How to fix it?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/chat_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_chat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v7.widget.RecyclerView>
<include layout="@layout/line_divider" />
<LinearLayout . . . >
</LinearLayout>
public class ChatBottomSheetDialog extends BottomSheetDialogFragment {
private ArrayList<SheetObject> cardList;
private RecyclerSheetAdapter mAdapter;
private RecyclerView recyclerView;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.sheet_chat, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view_chat);
cardList = new ArrayList<>();
mAdapter = new RecyclerSheetAdapter(this, cardList);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(),LinearLayoutManager.HORIZONTAL, false);
recyclerView.setLayoutManager(layoutManager);
//recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(mAdapter);
recyclerView.setHasFixedSize(true);
return view;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question