pedrovgs / DraggablePanel

Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.
Apache License 2.0
2.99k stars 606 forks source link

Top fragment not resized properly when height is set programmatically #84

Open tuncaulubilge opened 8 years ago

tuncaulubilge commented 8 years ago

I'm using a custom player as the top fragment for draggablePanel. Everything works as expected if the height is fixed in the layout file. However, if I set the height on onCreateView manually, the height is not scaled down when minimized.

I need to make sure the player works in 16:9 aspect ratio, so the following code block is run on onCreateView for top fragment:

int width = ScreenUtil.getWidth(activity);
int playerHeight = (int) (width * 9.0 / 16);

View view = inflater.inflate(R.layout.fragment_player, container, false);
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.height = playerHeight;
brightcoveVideoView = (BrightcoveExoPlayerVideoView) view.findViewById(R.id.brightcoveVideoView);
brightcoveVideoView.setLayoutParams(layoutParams);

Here are my draggablePanel configurations. Same player height is set for setTopViewHeight:

draggablePanel.setFragmentManager(getSupportFragmentManager());
draggablePanel.setTopFragment(playerFragment);
draggablePanel.setBottomFragment(contentFragment);
draggablePanel.setTopViewHeight(playerFragment.getPlayerHeight());
draggablePanel.setTopFragmentMarginBottom((int) getResources().getDimension(R.dimen.double_separator));
draggablePanel.setTopFragmentMarginRight((int) getResources().getDimension(R.dimen.double_separator));
draggablePanel.setEnableHorizontalAlphaEffect(false);
draggablePanel.setClickToMaximizeEnabled(true);
draggablePanel.setXScaleFactor(2);
draggablePanel.setYScaleFactor(2);
draggablePanel.initializeView();
draggablePanel.setTopFragmentResize(true);

The custom player used in this example is Brightcove Video Player, a custom extension of Google's ExoPlayer library.

pedrovgs commented 8 years ago

Hi @tuncaulubilge I need to debug the code manually to know what's going on. Can you upload a sample project with your configuration?

LouisLin0706 commented 8 years ago

screenshot_2016-04-27-12-12-34

This is the problem i use the DraggablePanel 1.9 , setting topView resize "true" , there is still have some margin top for topView , Is there have any problem like this and fix it ?