是否可以将 Persistent Bottom Sheet 作为片段?

Nit*_*oid 5 android android-fragments android-design-library bottom-sheet

我想将 Persistent Bottom Sheet 制作为 Fragment 内的 Fragment,但找不到任何方法来实现它。无处不在的持久性底部表被添加为活动/片段内的布局,但是否可以将持久性底部表作为片段,以便我可以在其他地方重用该视图?

Mic*_*Lam 0

BottomSheetAndroidHive有一个很棒的教程

您可以创建一个扩展的类BottomSheetDialogFragment

public class BottomSheetFragment extends BottomSheetDialogFragment {
    public BottomSheetFragment() {
    // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_bottom_sheet_dialog, container, 
              false);
    }
}
Run Code Online (Sandbox Code Playgroud)

并使用下面的代码切换它

BottomSheetFragment bottomSheetFragment = new BottomSheetFragment();
bottomSheetFragment.show(getSupportFragmentManager(), bottomSheetFragment.getTag());
Run Code Online (Sandbox Code Playgroud)

  • 我不需要模态底板。我想要持久底页。 (6认同)