Closed hrsalehi closed 8 years ago
Hi, I just updated the sample with an example of this. Check out the new FullBottomSheetDialogFragment at: https://github.com/rubensousa/BottomSheetExample/blob/master/app/src/main/java/com/github/rubensousa/bottomsheetexample/ui/FullBottomSheetDialogFragment.java
public class FullBottomSheetDialogFragment extends BottomSheetDialogFragment
implements ItemAdapter.ItemListener {
private BottomSheetBehavior mBehavior;
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
View view = View.inflate(getContext(), R.layout.sheet, null);
view.findViewById(R.id.fakeShadow).setVisibility(View.GONE);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
ItemAdapter itemAdapter = new ItemAdapter(createItems(), this);
recyclerView.setAdapter(itemAdapter);
dialog.setContentView(view);
mBehavior = BottomSheetBehavior.from((View) view.getParent());
return dialog;
}
@Override
public void onStart() {
super.onStart();
mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
public List<Item> createItems() {
ArrayList<Item> items = new ArrayList<>();
items.add(new Item(R.drawable.ic_preview_24dp, "Preview"));
items.add(new Item(R.drawable.ic_share_24dp, "Share"));
items.add(new Item(R.drawable.ic_link_24dp, "Get link"));
items.add(new Item(R.drawable.ic_content_copy_24dp, "Copy"));
items.add(new Item(R.drawable.ic_preview_24dp, "Preview"));
items.add(new Item(R.drawable.ic_share_24dp, "Share"));
items.add(new Item(R.drawable.ic_link_24dp, "Get link"));
items.add(new Item(R.drawable.ic_content_copy_24dp, "Copy"));
items.add(new Item(R.drawable.ic_preview_24dp, "Preview"));
items.add(new Item(R.drawable.ic_share_24dp, "Share"));
items.add(new Item(R.drawable.ic_link_24dp, "Get link"));
items.add(new Item(R.drawable.ic_content_copy_24dp, "Copy"));
items.add(new Item(R.drawable.ic_preview_24dp, "Preview"));
items.add(new Item(R.drawable.ic_share_24dp, "Share"));
items.add(new Item(R.drawable.ic_link_24dp, "Get link"));
items.add(new Item(R.drawable.ic_content_copy_24dp, "Copy"));
return items;
}
@Override
public void onItemClick(Item item) {
mBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
}
}
@rubensousa while recyclerview scrolling ends BottomSheetDialogFragment should not be dragged down !! any ways to do that?
not working !
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_DRAGGING) {
mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
This however does not cover the toolbar, any idea how to achieve that?
@ishaan-khan Were you able to achieve that?
Hi I wrote a
BottomSheetDialogFragment
and inflated a custom view in it but i have a little problem doing these: