user3409897
user3409897

Reputation: 143

umano sothree.slidinguppanel.SlidingUpPanelLayout for bottom slideup panel height different for different phone screen szie

I am using umano sothree.slidinguppanel.SlidingUpPanelLayout for bottom slide up layout. I have set height for the umano panel layout as 400dp which match my phone small screen and design is correct. when application is installed on large screen phones the panel height is very small compared to the design.

How to make the panel always stay below a image and while scrolling the panel should slide up

    <com.sothree.slidinguppanel.SlidingUpPanelLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/sliding_layout"
        android:gravity="bottom"
        sothree:umanoPanelHeight="460dp"
        sothree:umanoShadowHeight="5dp"
        sothree:umanoDragView="@+id/dragView"
        sothree:umanoOverlay="true"
        sothree:umanoScrollableView="@+id/cl_dragged_view">

Upvotes: 0

Views: 19

Answers (1)

user3409897
user3409897

Reputation: 143

calculate the height of total screen.

DisplayMetrics displayMetrics = new DisplayMetrics();
                activityContext.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
                    int height1 = displayMetrics.heightPixels;

then calculate the height of the layout that the sliding panel should touch

 ViewTreeObserver vto = clLottiePanel.getViewTreeObserver();
            vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                        clLottiePanel.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                    } else {
                        clLottiePanel.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                    }
                    int height = binding.clLottiePanel.getMeasuredHeight();
                    DisplayMetrics displayMetrics = new DisplayMetrics();
                    .getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
                    int height1 = displayMetrics.heightPixels;
                    Log.d("TAG", "onGlobalLayout: ");
                  slidingLayout.setPanelHeight(height1 - height);

                }
            });

now

sidingLayout.setPanelHeight(height1 - height); 

this give the hieght for each screen to set for panel height.

Upvotes: 0

Related Questions