我看到几个库可以做到这一点,但如果可能的话,我想避免使用它们。我设法从左到右,但我不知道如何在两个方向上做。所以这是我的代码:
final SlidingPaneLayout slidingPaneLayout = SlidingPaneLayout.class.cast(root.findViewById(R.id.slidingpanelayout));
slidingPaneLayout.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View view, float v) {
}
@Override
public void onPanelOpened(View view) {
switch (view.getId()) {
case R.id.fragment_secondpane:
getSupportFragmentManager().findFragmentById(R.id.fragment_firstpane).setHasOptionsMenu(true);
getSupportFragmentManager().findFragmentById(R.id.fragment_secondpane).setHasOptionsMenu(false);
break;
default:
break;
}
}
@Override
public void onPanelClosed(View view) {
switch (view.getId()) {
case R.id.fragment_secondpane:
getSupportFragmentManager().findFragmentById(R.id.fragment_firstpane).setHasOptionsMenu(false);
getSupportFragmentManager().findFragmentById(R.id.fragment_secondpane).setHasOptionsMenu(true);
break;
default:
break;
}
}
});
有没有办法在从左到右和从右到左的方向上制作滑动面板,这样我就有 3 个片段,没有任何库?