本文整理汇总了Java中fr.castorflex.android.verticalviewpager.VerticalViewPager类的典型用法代码示例。如果您正苦于以下问题:Java VerticalViewPager类的具体用法?Java VerticalViewPager怎么用?Java VerticalViewPager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VerticalViewPager类属于fr.castorflex.android.verticalviewpager包,在下文中一共展示了VerticalViewPager类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onCreate
import fr.castorflex.android.verticalviewpager.VerticalViewPager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_vertical_parallax);
final ParallaxBackgroundView bg = (ParallaxBackgroundView) findViewById(R.id.parallax_bg);
bg.setParallaxBackgroundResource(R.drawable.vertical_parallax_bg);
// BitmapFactory.Options options = new BitmapFactory.Options();
// options.inJustDecodeBounds = true;
// BitmapFactory.decodeResource(getResources(), R.drawable.vertical_parallax_bg, options);
// options.inJustDecodeBounds = false;
// options.inSampleSize = 2;
// Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.vertical_parallax_bg, options);
// //noinspection deprecation
// bg.setParallaxBackground(new BitmapDrawable(bitmap));
VerticalViewPager pager = (VerticalViewPager) findViewById(R.id.pager);
final PagerAdapter adapter = new MyAdapter();
pager.setAdapter(adapter);
pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
// this is called while user's flinging with:
// position is the page number
// positionOffset is the percentage scrolled (0...1)
// positionOffsetPixels is the pixel offset related to that percentage
// so we got everything we need ....
float finalPercentage = ((position + positionOffset) * 100 / adapter.getCount()); // percentage of this page+offset respect the total pages
// now you have to scroll the background layer to this position. You can either adjust the clipping or
// the background X coordinate, or a scroll position if you use an image inside an scrollview ...
// I personally like to extend View and draw a scaled bitmap with a clipping region (drawBitmap with Rect parameters), so just modifying the X position then calling invalidate will do. See attached source ParallaxBackground
bg.setParallaxPercent(finalPercentage);
}
});
}
开发者ID:xpleemoon,项目名称:ParallaxBackgroundView,代码行数:36,代码来源:VerticalParallaxActivity.java
示例2: onCreate
import fr.castorflex.android.verticalviewpager.VerticalViewPager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VerticalViewPager pager = (VerticalViewPager) findViewById(R.id.verticalviewpager);
VerticalPageIndicator indicator = (VerticalPageIndicator) findViewById(R.id.indicator);
adapter = new DummyAdapter();
pager.setAdapter(adapter);
indicator.setVerticalViewPager(pager);
}
开发者ID:imablanco,项目名称:VerticalPageIndicator,代码行数:14,代码来源:MainActivity.java
示例3: onCreateView
import fr.castorflex.android.verticalviewpager.VerticalViewPager; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_monthly, container, false);
vvPager = (VerticalViewPager) v.findViewById(R.id.vviewPager);
vvPager.setAdapter(adapter);
vvPager.setOnPageChangeListener(adapter);
vvPager.setCurrentItem(adapter.getPosition(mYear, mMonth));
vvPager.setOffscreenPageLimit(1);
return v;
}
开发者ID:brownsoo,项目名称:Android-Vertically-Scrollable-Calendar-Prototype,代码行数:15,代码来源:MonthlyFragment.java
示例4: onCreateView
import fr.castorflex.android.verticalviewpager.VerticalViewPager; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_post_page_readability, container, false);
// against id collisions
view.setId(hashCode());
TextView postTitle = (TextView) view.findViewById(R.id.post_title);
VerticalViewPager verticalViewPager = (VerticalViewPager) view.findViewById(R.id.vertical_view_pager);
Fab fab = (Fab) view.findViewById(R.id.reddit_comment_fab);
// VerticalViewPagerCirclePageIndicator vvpcpi = (VerticalViewPagerCirclePageIndicator) view.findViewById(R.id.readability_post_indicator);
try {
postTitle.setText(postObject.getJSONObject("data").getString("title"));
String url = "http://readability.com/api/content/v1/parser" +
"?token=d48451fa7e61e79f0f7e215fe2258dc41b69ca75" +
"&url=" + postObject.getJSONObject("data").getString("url");
ReadabilityAdapter readabilityAdapter = new ReadabilityAdapter(getChildFragmentManager(), url);
verticalViewPager.setAdapter(readabilityAdapter);
// vvpcpi.setVoteViewPager(verticalViewPager);
} catch (JSONException e) {
e.printStackTrace();
}
postTitle.setOnTouchListener(new CollapseViewOnTouchListener());
return view;
}
开发者ID:geelenb,项目名称:YARR,代码行数:30,代码来源:ReadabilityPostPage.java
示例5: onCreateView
import fr.castorflex.android.verticalviewpager.VerticalViewPager; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View theView = inflater.inflate(R.layout.day_logs_chart_pager, container, false);
VerticalViewPager verticalViewPager = (VerticalViewPager) theView.findViewById(R.id.verticalviewpager);
verticalViewPager.setAdapter(getAdapter());
verticalViewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.pagemargin));
verticalViewPager.setPageMarginDrawable(new ColorDrawable(getResources().getColor(android.R.color.holo_green_dark)));
verticalViewPager.setPageTransformer(true, new ViewPager.PageTransformer() {
@Override
public void transformPage(View view, float position) {
int pageWidth = view.getWidth();
int pageHeight = view.getHeight();
if (position < -1) { // [-Infinity,-1)
// This page is way off-screen to the left.
view.setAlpha(0);
} else if (position <= 1) { // [-1,1]
// Modify the default slide transition to shrink the page as well
float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
float vertMargin = pageHeight * (1 - scaleFactor) / 2;
float horzMargin = pageWidth * (1 - scaleFactor) / 2;
if (position < 0) {
view.setTranslationY(vertMargin - horzMargin / 2);
} else {
view.setTranslationY(-vertMargin + horzMargin / 2);
}
// Scale the page down (between MIN_SCALE and 1)
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
// Fade the page relative to its size.
view.setAlpha(MIN_ALPHA +
(scaleFactor - MIN_SCALE) /
(1 - MIN_SCALE) * (1 - MIN_ALPHA));
} else { // (1,+Infinity]
// This page is way off-screen to the right.
view.setAlpha(0);
}
}
});
return theView;
}
开发者ID:graham22,项目名称:Classic,代码行数:48,代码来源:MonthPager.java
示例6: setVerticalViewPager
import fr.castorflex.android.verticalviewpager.VerticalViewPager; //导入依赖的package包/类
/**
* Init the indicator view based on the VerticalViewPager item count
* @param pager
*/
public void setVerticalViewPager(final VerticalViewPager pager){
pager.post(new Runnable() {
@Override
public void run() {
childCount = pager.getAdapter().getCount();
init(pager);
}
});
}
开发者ID:imablanco,项目名称:VerticalPageIndicator,代码行数:19,代码来源:VerticalPageIndicator.java
注:本文中的fr.castorflex.android.verticalviewpager.VerticalViewPager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论