单击浮动按钮后会出现自定义页脚菜单

时间:2016-05-16 18:40:26

标签: android material-design

如何在点击浮动按钮后应用材质设计动画来显示自定义页脚菜单?

Components – Buttons: Floating Action Button

1 个答案:

答案 0 :(得分:0)

首先创建一个类扩展BottomSheetDialogFragment

public class FooterSheetDialogFragment extends BottomSheetDialogFragment {


    public static FooterSheetDialogFragment newInstance() {
        return new FooterSheetDialogFragment();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.footer_al_dia, container, false);
        return v;
    }
}

第二:`

mFloatingButton = (FloatingActionButton) view.findViewById(R.id.floatingButtonAlDia);`
        mFloatingButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    BottomSheetDialogFragment bsdFragment = FooterSheetDialogFragment.newInstance();
                    bsdFragment.show(FragmentAlDia.this.getFragmentManager(), "BSDialog");
                }
            }
        );