Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android SlidingUpPanelLayout slide up event

I'm using https://github.com/umano/AndroidSlidingUpPanel. It works great, but I'm trying to figure out some way to listen for a sliding up/down event. I didn't really see anything relating to that in the README.

file.xml:

<com.sothree.slidinguppanel.SlidingUpPanelLayout
   xmlns:sothree="http://schemas.android.com/apk/res-auto"
   android:id="@+id/sliding_layout"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:gravity="bottom"
   sothree:fadeColor="@android:color/transparent"
   sothree:panelHeight="30dp"
   sothree:shadowHeight="4dp">

    <RelativeLayout android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin" >

        <!-- always visible content -->

    </RelativeLayout>


    <RelativeLayout android:id="@+id/slider"
        android:layout_width="match_parent"
        android:layout_height="250dp" >

        <!-- slide-able stuff -->

        <ImageView
            android:id="@+id/sliderImage"
            android:layout_width="match_parent"
            android:layout_height="20dp"
            android:src="@drawable/slide_up"
            android:gravity="center|top" />

        <ListView
            android:id="@+id/table"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/sliderImage" >

        </ListView>

    </RelativeLayout>

</com.sothree.slidinguppanel.SlidingUpPanelLayout>

someJava.java:

SlidingUpPanelLayout slider = (SlidingUpPanelLayout)findViewById(R.id.sliding_layout);
ImageView sliderImage = (ImageView)findViewById(R.id.sliderImage);

/* slider.setOnSomethingListenerIdk(new SomeSortOfOnSomethingListener(){
    @Override
    public boolean onSomething(View view, SomeEvent someEvent) {
         if (view.isUpOrSomething) sliderImage.setImageResource(R.drawable.slide_down);
         else sliderImage.setImageResource(R.drawable.slide_up);
    }
});*/

So basically I have an image of an arrowhead that I want to change when the bottom panel slides up or down. I am unable to figure out how to do this.

like image 438
Jared Price Avatar asked Aug 15 '14 15:08

Jared Price


People also ask

What is sliding up screen in Android?

Sliding Up Screen in Android Last Updated : 23 Feb, 2021 Sliding Up Screen is another common feature that we see in most of the apps. This Sliding Up Screen can be used for displaying some content after clicking the button or to display Menu.

What is slidingpanelayout?

SlidingPaneLayout provides a horizontal, multi-pane layout for use at the top level of a UI. A left (or start) pane is treated as a content list or browser, subordinate to a primary detail view for displaying content.

How to add a sliding up panel layout to an activity?

Include com.sothree.slidinguppanel.SlidingUpPanelLayout as the root element in your activity layout. The layout must have gravity set to either top or bottom. Make sure that it has two children.

How to make a sliding panel slide from the top?

You can set a PanelSlideListener to monitor events about sliding panes. You can also make the panel slide from the top by changing the layout_gravity attribute of the layout to top. You can provide a scroll interpolator for the panel movement by setting umanoScrollInterpolator attribute.


1 Answers

If i understand your question correctly, I think you might want to look at this

 /**
 * Listener for monitoring events about sliding panes.
 */
public interface PanelSlideListener {
    /**
     * Called when a sliding pane's position changes.
     * @param panel The child view that was moved
     * @param slideOffset The new offset of this sliding pane within its range, from 0-1
     */
    public void onPanelSlide(View panel, float slideOffset);
    /**
     * Called when a sliding panel becomes slid completely collapsed.
     * @param panel The child view that was slid to an collapsed position
     */
    public void onPanelCollapsed(View panel);

    /**
     * Called when a sliding panel becomes slid completely expanded.
     * @param panel The child view that was slid to a expanded position
     */
    public void onPanelExpanded(View panel);

    /**
     * Called when a sliding panel becomes anchored.
     * @param panel The child view that was slid to a anchored position
     */
    public void onPanelAnchored(View panel);

    /**
     * Called when a sliding panel becomes completely hidden.
     * @param panel The child view that was slid to a hidden position
     */
    public void onPanelHidden(View panel);
}`

....

 /**
 * Sets the panel slide listener
 * @param listener
 */
public void setPanelSlideListener(PanelSlideListener listener) {
    mPanelSlideListener = listener;
}

so basically this is how you do it.

slide.setPanelSlideListener(new PanelSlideListener(){
   // Override here
});

theres a demo over here

hope it helps :)

like image 190
Spurdow Avatar answered Oct 19 '22 19:10

Spurdow