多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當前位置:首頁 > 互聯(lián)網 > Android開發(fā)技巧――ViewPager衍生出來的2個類

Android開發(fā)技巧――ViewPager衍生出來的2個類

來源:程序員人生   發(fā)布時間:2014-09-08 11:36:39 閱讀次數(shù):2499次

1、不能左右滑動的ViewPager

/* * Date: 14-7-28 * Project: Access-Control-V2 */ package cn.irains.access.v2.common; import android.content.Context; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.MotionEvent; /** * Author: msdx (645079761@qq.com) * Time: 14-7-28 上午10:20 */ public class StaticViewPager extends ViewPager { public StaticViewPager(Context context) { super(context); } public StaticViewPager(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { return false; } @Override public boolean onTouchEvent(MotionEvent ev) { return false; } @Override public void setCurrentItem(int item) { this.setCurrentItem(item, false); } }

2、高度可以為WrapContent的ViewPager

/* * Date: 14-8-18 * Project: Access-Control-V2 */ package cn.irains.access.v2.common; import android.content.Context; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.View; /** * Author: msdx (645079761@qq.com) * Time: 14-8-18 上午11:22 */ public class WrapHeightViewPager extends ViewPager { public WrapHeightViewPager(Context context) { super(context); } public WrapHeightViewPager(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int height = 0; for (int i = 0; i < getChildCount(); i++) { View child = getChildAt(i); child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); int h = child.getMeasuredHeight(); if (h > height) height = h; } heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } /** * Determines the height of this view * * @param measureSpec A measureSpec packed into an int * @param view the base view with already measured height * @return The height of the view, honoring constraints from measureSpec */ private int measureHeight(int measureSpec, View view) { int result = 0; int specMode = MeasureSpec.getMode(measureSpec); int specSize = MeasureSpec.getSize(measureSpec); if (specMode == MeasureSpec.EXACTLY) { result = specSize; } else { // set the height from the base view if available if (view != null) { result = view.getMeasuredHeight(); } if (specMode == MeasureSpec.AT_MOST) { result = Math.min(result, specSize); } } return result; } }



 

生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 最近最新中文字幕8 | 国产成人永久免费视频 | 成人午夜又粗又硬有大 | 爱就操 | 国产三级精品三级在线观看 | 欧美老女人性视频 | 欧洲美女人牲交一级毛片 | 在线播放网站 | 亚洲三级久久 | 九月婷婷天天澡天天添天天爽 | 在线看网站 | 一区二区三区高清 | 国产精品v欧美精品v日韩 | 欧美13一14周岁a在线播放 | 日本欧美一区二区三区乱码 | 久久久久久国产精品免费免 | 亚洲一区欧美日韩 | 欧美三区在线观看 | 69av在线播放 | 一级毛片真人不卡免费播 | a级片在线免费看 | 国产美女无遮挡免费网站 | 久草在线网址 | 黄色免费网站网址 | 波多野结衣视频在线播放 | 中文字幕一区二区三区精彩视频 | 最近中文字幕版免费 | 日本一区二区三区在线 视频 | 亚洲精品不卡在线 | 亚洲视频二区 | 欧美性精品videofree | 成人淫片免费视频95视频 | 亚洲视频久久 | 在线播放精品 | 国产成人综合网亚洲欧美在线 | 亚洲欧美日本欧美在线播放污 | 欧美日韩一区二区三区免费 | 免费观看福利视频 | 亚洲小视频 | 一机毛片 | 91丨九色丨首页在线观看 |