Floating Action Button blocking other components

后端 未结 6 2309
粉色の甜心
粉色の甜心 2021-02-19 01:41

The new Material Design of Google recommends to use floating action buttons to draw attention to the user for the main action on that screen. There are quite a lot of examples o

6条回答
  •  情书的邮戳
    2021-02-19 02:38

    I just had this issue now, and I solved it this way:

    public void addBlankSpace(ListView listView)
    {
        Space space = new Space(listView.getContext());
        space.setMinimumHeight(Core.dpToPx(50));
        listView.addFooterView(space);
    }
    

    And I guess there is always a better way. like checking if you even need it. and only then to display it. but for now, this simple code works just fine.

    And here is the conversion function:

    public static int dpToPx(int dp)
    {
        return (int)(dp * Resources.getSystem().getDisplayMetrics().density);
    }
    

    Or we can just add some padding:

    listView.setPadding(0, 0, 0, Core.dpToPx(50));
    

提交回复
热议问题