谁能帮我看看代码!帮我看看这个代码具体实现什么功能。

ydicky_j 发布于 2015/06/15 11:08
阅读 130
收藏 0
public class BigDragableLuncher extends ViewGroup {


// 按钮背景色
int choseColor, defaultColor;
// 底部按钮数组
ImageButton[] bottomBar;
// 负责得到滚动属性的对象
private Scroller mScroller;
// 滚动的起始X坐标
private int mScrollX = 0;
// 默认显示第几屏
private int mCurrentScreen = 0;


public int mTouchSlop = 0;


public BigDragableLuncher(Context context) {
super(context);
mScroller = new Scroller(context);
// 得到状态位
mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();


this.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.FILL_PARENT));
}


public BigDragableLuncher(Context context, AttributeSet attrs) {
super(context, attrs);
mScroller = new Scroller(context);


mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();


this.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,


ViewGroup.LayoutParams.FILL_PARENT));


TypedArray a = getContext().obtainStyledAttributes(attrs,
R.styleable.DragableLuncher);
mCurrentScreen = a.getInteger(
R.styleable.DragableLuncher_default_screen, 0);
}


public void setBottomBarBg(ImageButton[] ib, int choseColor,
int defaultColor) {
this.bottomBar = ib;
this.choseColor = choseColor;
this.defaultColor = defaultColor;
}


public void snapToDestination() {
final int screenWidth = getWidth();
final int whichScreen = (mScrollX + (screenWidth / 2)) / screenWidth;
snapToScreen(whichScreen);

}


加载中
返回顶部
顶部