Java Code Examples for android.support.v4.view.ViewPager#LayoutParams
The following examples show how to use
android.support.v4.view.ViewPager#LayoutParams .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecyclablePagerAdapter.java From vlayout with MIT License | 5 votes |
/** * Get view from position * * @param container * @param position * @return */ @Override public Object instantiateItem(ViewGroup container, int position) { int itemViewType = getItemViewType(position); RecyclerView.ViewHolder holder = mRecycledViewPool.getRecycledView(itemViewType); if (holder == null) { holder = mAdapter.createViewHolder(container, itemViewType); } onBindViewHolder((VH) holder, position); //itemViews' layoutParam will be reused when there are more than one nested ViewPager in one page, //so the attributes of layoutParam such as widthFactor and position will also be reused, //while these attributes should be reset to default value during reused. //Considering ViewPager.LayoutParams has a few inner attributes which could not be modify outside, we provide a new instance here ViewPager.LayoutParams layoutParams = new ViewPager.LayoutParams(); if (holder.itemView.getLayoutParams() != null) { layoutParams.width = holder.itemView.getLayoutParams().width; layoutParams.height = holder.itemView.getLayoutParams().height; } container.addView(holder.itemView, layoutParams); return holder; }
Example 2
Source File: MainActivity.java From YViewPagerDemo with Apache License 2.0 | 5 votes |
private void initImages() { mImageViews = new ArrayList<>(); ViewPager.LayoutParams lp=new ViewPager.LayoutParams(); lp.gravity= Gravity.LEFT; ImageView imageView1 = new ImageView(this); imageView1.setImageResource(R.drawable.jay_fantexi); imageView1.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView2 = new ImageView(this); imageView2.setImageResource(R.drawable.jay_jay); imageView2.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView3 = new ImageView(this); imageView3.setImageResource(R.drawable.image2); imageView3.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView4 = new ImageView(this); imageView4.setImageResource(R.drawable.jay_jay); imageView4.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView5 = new ImageView(this); imageView5.setImageResource(R.drawable.logo); imageView5.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView1.setLayoutParams(lp); imageView2.setLayoutParams(lp); imageView3.setLayoutParams(lp); imageView4.setLayoutParams(lp); imageView5.setLayoutParams(lp); mImageViews.add(imageView1); mImageViews.add(imageView2); mImageViews.add(imageView3); mImageViews.add(imageView4); mImageViews.add(imageView5); }
Example 3
Source File: ScrollerPager.java From AdPlayBanner with Apache License 2.0 | 5 votes |
/** * 装载ScrollerPager */ private void addScrollerPager() { ViewPager.LayoutParams layoutParams = new ViewPager.LayoutParams(); layoutParams.width = ViewPager.LayoutParams.MATCH_PARENT; layoutParams.height = ViewPager.LayoutParams.MATCH_PARENT; mContainer.addView(this, layoutParams); }
Example 4
Source File: PagerIndicator.java From RunMap with Apache License 2.0 | 5 votes |
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); final ViewParent parent = getParent(); if (!(parent instanceof ViewPager)) { throw new IllegalStateException("PagerIndicator must be a direct child of a ViewPager."); } ((ViewPager.LayoutParams) getLayoutParams()).isDecor = true; mParentPager = (ViewPager) parent; mParentPager.addOnPageChangeListener(this); }
Example 5
Source File: EmojiBorad.java From umeng_community_android with MIT License | 5 votes |
/** * create ViewPager view</br> * * @return */ private ViewPager createVIewpager() { ViewPager viewPager = new ViewPager(getContext()); ViewPager.LayoutParams params = new ViewPager.LayoutParams(); params.width = android.support.v4.view.ViewPager.LayoutParams.MATCH_PARENT; params.height = BOARD_HEIGHT; viewPager.setLayoutParams(params); viewPager.setPadding(0, 15, 0, 0); return viewPager; }
Example 6
Source File: BannerActivity.java From YViewPagerDemo with Apache License 2.0 | 4 votes |
private void initImgs() { mImageViews = new ArrayList<>(); mStringList=new ArrayList<>(); ViewPager.LayoutParams lp = new ViewPager.LayoutParams(); lp.gravity = Gravity.LEFT; ImageView imageView1 = new ImageView(this); imageView1.setImageResource(R.drawable.jay_fantexi); imageView1.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView2 = new ImageView(this); imageView2.setImageResource(R.drawable.jay_jay); imageView2.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView3 = new ImageView(this); imageView3.setImageResource(R.drawable.logo); imageView3.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView4 = new ImageView(this); imageView4.setImageResource(R.drawable.image2); imageView4.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView5 = new ImageView(this); imageView5.setImageResource(R.drawable.jay_jay); imageView5.setScaleType(ImageView.ScaleType.CENTER_CROP); ImageView imageView6 = new ImageView(this); imageView6.setImageResource(R.drawable.logo); imageView6.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView1.setLayoutParams(lp); imageView2.setLayoutParams(lp); imageView3.setLayoutParams(lp); imageView4.setLayoutParams(lp); imageView5.setLayoutParams(lp); imageView6.setLayoutParams(lp); mImageViews.add(imageView1); mImageViews.add(imageView2); mImageViews.add(imageView3); mImageViews.add(imageView4); mImageViews.add(imageView5); mImageViews.add(imageView6); mStringList.add("youngkaaa test 1"); mStringList.add("hahahahha"); mStringList.add("yyyyyyyyyyyyyyy"); mStringList.add("aaaaaaaaaaaaaa"); mStringList.add("pipipipipipipipipi"); mStringList.add("kkkkkkkkkkkkkkkkk"); }
Example 7
Source File: YViewPagerNew.java From YViewPagerDemo with Apache License 2.0 | 4 votes |
@Override protected ViewGroup.LayoutParams generateDefaultLayoutParams() { return new ViewPager.LayoutParams(); }
Example 8
Source File: JazzyViewPager.java From letv with Apache License 2.0 | 4 votes |
public void addView(View child, ViewPager.LayoutParams params) { super.addView(wrapChild(child), params); }
Example 9
Source File: JazzyViewPager.java From letv with Apache License 2.0 | 4 votes |
public void addView(View child, int index, ViewPager.LayoutParams params) { super.addView(wrapChild(child), index, params); }