我想实现滑块菜单就像Facebook的Android应用了。安卓滑盖执行
我已成功滑动菜单并将其重新滑回。
我有两个视图适合framelayout。
1.主要laout(X)
2.菜单布局。(Y)
我滑动X到右示出上滑动和上滑回我移动X回到0其中隐藏菜单ÿ。
@Override
public void setContentView(int layout) {
FrameLayout frame = new FrameLayout(getBaseContext());
frame.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT));
LayoutInflater inflator = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mainLayout = inflator.inflate(layout, null);
menuList = inflator.inflate(R.layout.menu_page, null);
fakeView= inflator.inflate(R.layout.fake_transparent_view, null);
menuAnimator = new MenuAnimation(mainLayout,menuList,fakeView);
frame.addView(menuList);
frame.addView(mainLayout);
frame.addView(fakeView);
fakeView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(mainLayout.getLeft()>0)
{
menuAnimator.moveMenu("left");
}
}
});
super.setContentView(frame);
}
public void moveMenu(String direction) {
int width=(int) (QuikrApplication.getWidth()*.85);
if (direction.equals("right")) {
this.direction="right";
fakeView.setVisibility(View.VISIBLE);
TranslateAnimation moveRight = new TranslateAnimation(0, width, 0, 0);
moveRight.setDuration(500);
parentLayout.setAnimation(moveRight);
moveRight.setAnimationListener(animationListner);
parentLayout.startAnimation(moveRight);
fakeView.startAnimation(moveRight);
}
else if (direction.equals("left")){
this.direction="left";
TranslateAnimation moveLeft = new TranslateAnimation(0, -width, 0, 0);
moveLeft.setDuration(500);
parentLayout.setAnimation(moveLeft);
moveLeft.setAnimationListener(animationListner);
parentLayout.startAnimation(moveLeft);
fakeView.startAnimation(moveLeft);
}
}
现在的问题是,当我做在主视图中的某些动作异步主要观点是重新定位(当菜单可见)
为什么你需要自己的实现,如果已经有几个好的? – Evos