我需要在我的应用程序中实现画中画模式。
- 在我的应用程序时钟页面中,当我选择时间时,定时器在画中画模式视图中启动。下课要不要大屏?
- 在画中画视图中,如何创建自定义布局?
注意:我在此类中使用片段(如何以android:supportsPictureInPicture="true"
编程方式为片段类设置此行)
我附上了示例图片供您参考。请参考。
我需要在我的应用程序中实现画中画模式。
注意:我在此类中使用片段(如何以android:supportsPictureInPicture="true"
编程方式为片段类设置此行)
我附上了示例图片供您参考。请参考。
我正在使用 DraggblePanel 获得相同类型的效果
private void initializeDraggablePanel(Fragment fragmentView, Fragment bottomFragment) {
draggablePanel.removeAllViews();
draggablePanel.setFragmentManager(getSupportFragmentManager());
draggablePanel.setTopFragment((Fragment) fragmentView);
draggablePanel.setBottomFragment(bottomFragment);
draggablePanel.setVisibility(View.VISIBLE);
draggablePanel.setClickToMaximizeEnabled(true);
draggablePanel.setDraggableListener(new DraggableListener() {
@Override
public void onClosedToLeft() {
draggablePanel.removeAllViews();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
@Override
public void onMinimized() {
isFullScFromMini = true;
pipHandler.removeCallbacks(runnapipa);
pipHandler.postDelayed(runnapipa, PIP_DELAY);
draggablePanel.disableBottomView(true);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
@Override
public void onClosedToRight() {
draggablePanel.removeAllViews();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
@Override
public void onUnMaximized() {
draggablePanel.disableBottomView(false);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
@Override
public void onMaximized() {
isFullScFromMini = true;
pipHandler.removeCallbacks(runnapipa);
pipHandler.postDelayed(runnapipa, PIP_DELAY);
draggablePanel.disableBottomView(false);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
}
});
TypedValue typedValue = new TypedValue();
getResources().getValue(R.dimen.x_scale_factor, typedValue, true);
float xScaleFactor = typedValue.getFloat();
typedValue = new TypedValue();
getResources().getValue(R.dimen.y_scale_factor, typedValue, true);
float yScaleFactor = typedValue.getFloat();
draggablePanel.setXScaleFactor(xScaleFactor);
draggablePanel.setYScaleFactor(yScaleFactor);
draggablePanel.setTopViewHeight(
getResources().getDimensionPixelSize(R.dimen.top_fragment_height));
draggablePanel.setTopFragmentMarginRight(
getResources().getDimensionPixelSize(R.dimen.top_frag_right_margin));
draggablePanel.setTopFragmentMarginBottom(
getResources().getDimensionPixelSize(R.dimen.top_fragment_margin));
draggablePanel.initializeView();
draggablePanel.maximize();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
}
有关完整的示例检查链接