0

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!

androidYS
  • 55
  • 6
  • Do you want to open listview from bottom to top? – Nilesh Panchal Feb 11 '19 at 07:17
  • @NileshPanchal From the bottom to a certain point on screen, I don't want it to cover the whole view. – androidYS Feb 11 '19 at 07:44
  • For that, you need to implement bottom sheet view and inside bottom sheet load recycler view with your desired data and maintain your view with a callback listener if you want some actions in the recycler view. – Nilesh Panchal Feb 11 '19 at 07:51
  • @NileshPanchal Why RecyclerView and not ListView? What difference does it make? with dewbamb's answer I've used ListView inside a bottom sheet and drawn it from the bottom. The only thing I'm not sure yet is how it will work when I will change the adapter to another adapter with less or more items. usually that's when the ordinary ListView gets corrupted – androidYS Feb 11 '19 at 09:29
  • Here you can find a difference -> https://stackoverflow.com/questions/26728651/recyclerview-vs-listview" – Nilesh Panchal Feb 11 '19 at 09:33

2 Answers2

0

I guess you need an inverted list in your listview. To do that, do this in your adapter:

String item = getItem(getCount()-position-1);
Sagar Balyan
  • 438
  • 4
  • 15
0

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

dewbambs
  • 96
  • 1
  • 11