The result is as follows: I think you have already seen it in many applications. Next let's take a look at how to achieve the sliding drawer effect using SlidingDrawer.
Android. widget. SlidingDrawer class has been added since Android1.5.
Some attributes of the SlidingDrawer control:
Android: allowSingleTap
Indicates whether handle can be enabled or disabled.
Android: animateOnClick indicates whether to enable or disable an animation when the user presses the handle.
Android: hidden content
Android: handle
Layout file:
[Html]
<LinearLayout
Xmlns: android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent"
Android: orientation = "vertical"
Android: background = "@ drawable/f">
<TextView
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: gravity = "center_vertical | center_horizontal"/>
<SlidingDrawer
Android: id = "@ + id/slidingdrawer"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: content = "@ + id/content"
Android: handle = "@ + id/handle"
Android: orientation = "vertical">
<ImageView
Android: id = "@ id/handle"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: src = "@ drawable/music_list_btn">
</ImageView>
<LinearLayout
Android: id = "@ id/content"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent"
Android: background = "@ drawable/t">
<TextView
Android: layout_width = "match_parent"
Android: layout_height = "match_parent"
Android: text = "hidden content"/>
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
The above results have been achieved through the layout file. In addition, SlidingDrawer provides some methods:
[Java]
SlidingDrawer sd = (SlidingDrawer) findViewById (R. id. slidingdrawer );
Sd. setOnDrawerOpenListener (new OnDrawerOpenListener (){
Public void onDrawerOpened (){
// TODO Auto-generated method stub
}
});
Sd. setOnDrawerCloseListener (new OnDrawerCloseListener (){
Public void onDrawerClosed (){
// TODO Auto-generated method stub
}
});
Sd. setOnDrawerScrollListener (new OnDrawerScrollListener (){
Public void onScrollEnded (){
// TODO Auto-generated method stub
}
Public void onScrollStarted (){
// TODO Auto-generated method stub
}
});