I'm creating an app and I want to draw my listView from the bottom, or a similar object to be drawn from the bottom and being able to select from its options.
I've tried setting Y position, defining layoutParams at listView setup, using layout gravity GravityCompact.START|Gravity.BOTTOM, stackFromBottom="true", I even tried pre setting up my listView but because I use the listView for different adapters with different amount of items it mostly start from somewhere in the center of the view.
I expect to manage to draw my listView from the bottom when it is aligned to the bottom, or even using a different option of android to draw a view from the bottom containing few clickable items.
Thanks!
As much I understand your question. You need to implement a bottom sheet. Which can be drawn out from bottom and can contain a list view. There are two types of bottom sheet modal and persistent to know more follow this link.
This is the code which you need to write to implement bottom sheet in your app.
create a java file called BottomSheet and a layout file called bottom_sheet.xml.
java file will look like this.
public class BottomSheet extends BottomSheetDialogFragment {
AdapterMessage adapterMessage;
ArrayList<MessageModel> messageList;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.bottom_sheet, container, false);
return view;
}
}
And then Implement your listView in this file and layout.
To call the bottom sheet you can use the following command.
BottomSheet bottomSheet = new BottomSheet();
bottomSheet.show((getSupportFragmentManager() ,"bottom sheet message");
For some proper tutorial on how to use bottom sheet