开发者

Android - Create animation 'Drag Up To Lock'

Does anyone have even a remote idea of how to create an animation like the one shown in the Pocket App where the user can drag a small bar (like the not开发者_运维技巧ification bar) from the bottom of the screen all the way up, making the app lock itself and change the current activity?

I'm just wondering how to do the animation, if it is a built in thing in android, or something more complexe. Can anyone give me some guidance of how to search/build a similar animation, please?

For those who are not familiar with the animation and do not know the app /did not understand my description, you can see it here

Thanks guys.


You could tryout the sliding drawer.

Or for this sort of animation you will need a layout which you place in the bottom and add a onThumbTouchListener.

Something like this

OnTouchListener onThumbTouch = new OnTouchListener()
    {
        @Override
        public boolean onTouch(View v, MotionEvent event) 
        {   
            switch(v.getId())
            {
                case R.id.slider_thumb_id:
                {
                    switch(event.getAction())
                    {
                        case MotionEvent.ACTION_MOVE:
                        {                           
                            if(v.getTop()>=0 && v.getBottom()<sliderFrame.getMeasuredHeight()){
                                int topPos = (int)event.getRawY()-(v.getHeight()*2+v.getHeight());
                                if(topPos < 0) {
                                    topPos=0;
                                } else if(topPos > (sliderFrame.getMeasuredHeight()-v.getMeasuredHeight())){
                                    topPos = (sliderFrame.getMeasuredHeight()-v.getMeasuredHeight()) -1;
                                }   
                                iconParams.topMargin = topPos;
                                v.setLayoutParams(iconParams);
                                sliderThumbFake.setLayoutParams(iconParams);
                            }                           
                            break;
                        }
                        case MotionEvent.ACTION_UP:
                        {                           

                        }
                    }
                    break;
                }
            }
            return true;
        }
    };

The code inside the case statements might not be useful as it was something I sued for my requirement. But this how you do a drag of a view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜