zoukankan      html  css  js  c++  java
  • 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 中自定义一个类来实现和封装的。

  • 相关阅读:
    android性能优化之布局优化
    android性能调优之traceview的使用
    android性能优化
    EditText光标居上
    ExecutorService的submit(Runnable x)和execute(Runnable x) 两个方法的本质区别
    android 静默安装
    android 内存优化
    image-webpack-loader在mac或ubuntu报错
    git重命名文件和文件夹
    js判断设备类型
  • 原文地址:https://www.cnblogs.com/aaa2832/p/2594049.html
Copyright © 2011-2022 走看看