我想製作一個下拉菜單,如狀態菜單,當活動開始時隱藏,當它被按下或滑動時,它會像下圖所示打開。我該如何製作一個隱藏下拉菜單
http://i.stack.imgur.com/jeq5z.png
我的佈局目前在其頂部欄和滾動型對那些之間的文本..一個RelativeLayout的,我想將菜單..
我不會做這個應用程序phonegap或類似的東西,只是java和xml ..
在此先感謝
編輯: 謝謝大家的幫助!我最終做了一個FrameLayout,這個FrameLayout被翻譯成了Y,然後,當點擊時,只是上下滑動。這裏是剪切..我會留在這裏以防別人需要它。
上layout.xml
<FrameLayout
android:id="@+id/layout_FrameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00ffffff" >
<!-- stuf -->
</FrameLayout>
上activity.java
private FrameLayout statusDrawer = null;
private int statusDrawerHeight; // height of the FrameLayout (generated automatically)
private int statusDrawerDragButtonHeight = 30 + 5; //height of the DragButton + height of the border
private boolean statusDrawerOpened = false;
private int statusDrawerDuration = 750; //time in milliseconds
private TimeInterpolator interpolator = null; //type of animation [email protected]/reference/android/animation/TimeInterpolator.html
@Override
protected void onCreated(Bundle savedInstanceState){
statusDrawer = (FrameLayout) findViewById(R.id.layout_FrameLayout);
interpolator = new AccelerateDecelerateInterpolator();
statusDrawer.post(new Runnable() {
@Override
public void run() {
statusDrawerHeight = statusDrawer.getHeight();
statusDrawer.setTranslationY(-statusDrawerHeight+statusDrawerDragButtonHeight);
}
});
statusDrawer.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v){
if(statusDrawerOpened) {
statusDrawer.animate()
.translationY(-statusDrawerHeight+statusDrawerDragButtonHeight)
.setDuration(statusDrawerDuration)
.setInterpolator(interpolator)
.start();
} else {
statusDrawer.animate()
.translationY(0)
.setDuration(statusDrawerDuration)
.setInterpolator(interpolator)
.start();
}
statusDrawerOpened = !statusDrawerOpened;
}
});
}
這個鏈接可以幫助你:) http://stackoverflow.com/questions/13377361/how-to-create- a-drop-down-list-in-android –