-2
這是我的代碼,我使用一個片段作爲滑動窗口,但窗口不可拖動。如何從Android中的屏幕底部滑動一個活動
Fragment fg= new addplace();
FragmentManager f = getSupportFragmentManager();
FragmentTransaction trans = f.beginTransaction().add(R.id.gg,fg);
trans.commit();
Interpolator ip = new OvershootInterpolator(5);
fl.animate().setInterpolator(ip).translationYBy(-200).setDuration(250);
fl.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction())
{
case MotionEvent.ACTION_DOWN:
mlastY=event.getY();
return true;
case MotionEvent.ACTION_MOVE:
double currentY=event.getY();
double deltaY=mlastY-currentY;
double transY = v.getTranslationY();
transY-=deltaY;
if(transY<0){
transY = 0;
}
transY=v.getTranslationY();
}
return false;
}
});
return false;}
});
}
我不能拖動screen.If任何人都可以請幫我這一點。