How can I open a SlidingDrawer using a button not attached to it? In other words, I like to open it w/o the handle.
在SlidingDrawer
上调用open()
。
Calling .open()
and .close()
makes the drawer appear and disappear without animation. I don't know if this is generally the case - I tested this on 4.03 with the drawer in a RelativeLayout
and it just popped into view without animation.
To make the SlidingDrawer
open and close by sliding into the View when clicking a button, use:
slidingDrawer.animateOpen();
and
slidingDrawer.animateClose();
Im not sure if you still need help or not but I was just wondering the same thing.
"SlidingDrawer" is our object called "slider":
SlidingDrawer slider = (SlidingDrawer) findViewById(R.id.SlidingDrawer);
Call the method "open()", using our object name:
slider.open();
Example button that just opens the sliding drawer:
Button next = (Button) findViewById(R.id.Button01);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
slider.open();
}
});
您需要覆盖手柄的触摸方法并将触摸事件传递给按钮。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.