1

I need to implement Picture In Picture mode in my app.

  1. In my app time clock page when i choose time, timer is start in picture in picture mode view. Remaining class should big screen?
  2. In picture in picture view, how to create custom layout?

Note: I am using fragment in this class (how to set this line android:supportsPictureInPicture="true" in programatically for fragment class)

I have attached sample images for your reference. kindly refer it.

enter image description here

Ajay Mehta
  • 843
  • 5
  • 14
New
  • 152
  • 1
  • 2
  • 12

1 Answers1

0

I'm using DraggblePanel For same type of effect

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);
    }

For complete Example check Link

ADM
  • 20,406
  • 11
  • 52
  • 83
Ganesh Pokale
  • 1,538
  • 1
  • 14
  • 28