Java – use the slidinguppanel library to keep the bottom view
I used slidinguppanel Library in one of my media player applications
In the slide panel, I have media controls. I want to display the artwork of the track at the top My problem is that I want the media control to always stay at the bottom of the screen (even if the user drags the panel, which means I have to use the onpanelslide () method) Maybe like parallax effect (I don't know if it's the right name) This is what I do now:
Collapse / expand / drag:
As you can see, when I drag the panel, the control is pasted on the top I want it to stick to the bottom of the screen and put the art directly above
I'm thinking about coordinatorlayout, but I don't know how to work!
My code:
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <com.sothree.slidinguppanel.SlidingUpPanelLayout android:id="@+id/sliding_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="bottom" sothree:umanoPanelHeight="92dp" sothree:umanoShadowHeight="4dp"> <ListView android:layout_width="match_parent" android:layout_height="match_parent"/> <include layout="@layout/details_slide_bar" /> </com.sothree.slidinguppanel.SlidingUpPanelLayout> </RelativeLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="bottom" android:orientation="vertical"> <ImageView android:id="@+id/ivArtworkBar" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:visibility="gone"/> <RelativeLayout android:layout_width="match_parent" android:layout_height="92dp" android:orientation="horizontal" android:id="@+id/lDetailsBar"> /!-- Content of the detalBar !--> </RelativeLayout> </LinearLayout>
Now, I just check the status of the panel and adjust the visibility of the art accordingly
There must be another way!
Solution
First, create your activity
mLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
Then set the panel state to fold
mLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); mLayout.setEnableDragViewTouchEvents(false); mLayout.setDragView(null); mLayout.setEnabled(false); mLayout.setClickable(false);
In addition, if your sliding panel is not visible, then
mLayout.setPanelHeight(your panel height);
Here, your panel height value must be an integer Or even like mlayout Setpanelheight (your_drag_layout. Getheight()) executes dynamically;