일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- ios framework
- embedd
- Android NDK시스템
- 공인인증서 정보
- IOS10
- sha1 convert hashkey
- v8 engine xcode build
- Magnify Anim
- Status Bar
- apns
- 인증서 정보 뽑아내기
- android log dump
- V8 Engine
- Objective C
- Android
- Google V8 Engine
- Push
- JavaScript Engine
- ios
- IMAGE
- java
- so file
- PageControl
- 안드로이드
- apache
- apk 다운사이징
- FlexiblePageView
- 공인인증서 만료일
- SO 파일
- appbarlayout
- Today
- Total
caTea 블로그
vertical view pager 본문
package com.ubist.tourtainment.mos.common.views;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
public class VerticalViewPager extends ViewPager{
private final String TAG = "VerticalViewPager";
public VerticalViewPager(Context context) {
this(context, null);
}
public VerticalViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
setPageTransformer(true, new VerticalPageTransformer());
setOverScrollMode(OVER_SCROLL_NEVER);
}
private class VerticalPageTransformer implements ViewPager.PageTransformer {
@Override
public void transformPage(View view, float position) {
if (position < -1) {
view.setAlpha(0);
} else if (position <= 1) {
view.setAlpha(1);
view.setTranslationX(view.getWidth() * -position);
float yPosition = position * view.getHeight();
view.setTranslationY(yPosition);
} else {
view.setAlpha(0);
}
}
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev){
boolean intercepted = super.onInterceptTouchEvent(swapXY(ev));
swapXY(ev);
return intercepted;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
return super.onTouchEvent(swapXY(ev));
}
private MotionEvent swapXY(MotionEvent ev) {
float width = getWidth();
float height = getHeight();
float newX = (ev.getY() / height) * width;
float newY = (ev.getX() / width) * height;
ev.setLocation(newX, newY);
return ev;
}
}
'android' 카테고리의 다른 글
android frame animation class (0) | 2017.02.22 |
---|---|
android permission activity (0) | 2017.02.22 |
이미지 라운드 처리 클래스 (0) | 2016.06.28 |
android file upload and spring(image..) (1) | 2015.08.05 |
android file path (0) | 2015.08.05 |