indicator之小究

一,源生launcher2

源生的indicator就是idle界面最下面功能条两边的总共4个点默认workspace5屏,当前屏幕相当于一个点,代码控制:

 private Drawable mPreviousIndicator;

 private Drawable mNextIndicator;

分别是左右两边的点集合对象,通过调用一下方法实现indicator的支援切换:

mPreviousIndicator.setLevel(mCurrent);

mNextIndicator.setLevel(numScreens-mCurrent-1);

二,launcherADW

该launcher的indicator可分为3类:

public static final int INDICATOR_TYPE_PAGER=1;

public static final int INDICATOR_TYPE_SLIDER_TOP=2;

public static final int INDICATOR_TYPE_SLIDER_BOTTOM=3;

INDICATOR_TYPE_PAGER

是圆点形式出现在页面最上面类似于三星桌面,INDICATOR_TYPE_SLIDER_TOP和INDICATOR_TYPE_SLIDER_BOTTOM

是样式类似于HTC分别出现在上面和下面的indicator。

 workspace中:

用的indicator是在launcher文件里面实例化的:private DesktopIndicator mDesktopIndicator;通过里面的public方法:public DesktopIndicator getDesktopIndicator()

得到实例进行相关的操作:mLauncher.getDesktopIndicator().indicate((float)mScroller.getCurrX()/(float)(getChildCount()*getWidth()));

mLauncher.getDesktopIndicator().hide();

mLauncher.getDesktopIndicator().

show();

AllAppSlidingView中:

private PreviewPager mPager;

其实是PreviewPager对indicator进行了源初始化和封装:

if(themeResources!=null){

resource_id=themeResources.getIdentifier ("pager_dots", "drawable", themePackage);

}


int dotWidth=getResources().getDrawable(mDotDrawableId).getIntrinsicWidth();

int separation=dotWidth;

int marginLeft=((getWidth())/2)-(((mTotalItems*dotWidth)/2)+(((mTotalItems-1)*separation)/2));

int dotMarginTop=((getHeight())/2)-(dotWidth/2);

然后通过方法mPager.setCurrentItem(whichScreen);来改变indicator的样式。

:DesktopIndicator 中的三种确切的可以分为两种:PreviewPager和SliderIndicator,前者是PreviewPager的引用,后者是在DesktopIndicator 中自定义一个类来实现和封装的。

posted @ 2011-11-26 11:35  紫璐宇  阅读(209)  评论(0编辑  收藏  举报