slideup - Create a panel that slides up and out of the screen in Android -
i need guidance. need make custom view touched , drag screen slides out of screen. have tried cool library: here dependend 2 layouts. 1 slided out , 1 remains after that. have buggy , ugly.
public class demoactivity extends activity { private slidinguppanellayout mlayout; private relativelayout layout; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_demo); layout = (relativelayout) findviewbyid(r.id.panel); final int defaulttop = layout.gettop(); final int defaultbottom = layout.getbottom(); relativelayout dragview = (relativelayout) findviewbyid(r.id.dragview); mlayout = (slidinguppanellayout) findviewbyid(r.id.sliding_layout); mlayout.setdragview(dragview); mlayout.setpanelslidelistener(new panelslidelistener() { @override public void onpanelslide(view panel, float slideoffset) { } @override public void onpanelexpanded(view panel) { system.out.println("panel expanded"); } @override public void onpanelcollapsed(view panel) { system.out.println("panel collapsed"); } @override public void onpanelanchored(view panel) { system.out.println("anchored"); } @override public void onpanelhidden(view panel) { system.out.println("panel hidden now"); } }); } @override public void onbackpressed() { if (mlayout != null && mlayout.ispanelexpanded()) { mlayout.collapsepanel(); } else { super.onbackpressed(); } }
}
the layout:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".demoactivity" > <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:background="@android:color/transparent" android:gravity="bottom" sothree:dragview="@+id/dragview" sothree:panelheight="60dp" sothree:paralaxoffset="60dp" sothree:shadowheight="0dp" > <relativelayout android:id="@+id/panel" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/unt" android:orientation="vertical" > <button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerinparent="true" android:layout_gravity="center" android:text="sleep" /> </relativelayout> <relativelayout android:id="@+id/dragview" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/transparent" android:clickable="true" android:focusable="false" > </relativelayout> </com.sothree.slidinguppanel.slidinguppanellayout> </relativelayout>
it slides leaves white background in back. if touch screen slides. so, need new path. did confrunted similar? need hint, not code. thanks.
i have used library mentioned here , worked out fine me. might have not set drag view/layout
do use mslidingpanellayout.setdragview(yourlayout) set layout can dragged
Comments
Post a Comment