任何问题请联系WX:uu16853

买模板送网站采集器 让你轻松放开双手运营网站!

购买更多有优惠!

Android自绘GridView控件 Android开发技术

  Android为我们提供了一个很好用的网格控件GridView,它的另外一种实现Google在提供PSDK时包含了一个简单的例子,大家一起来看看吧: 对于还不熟悉Android平台控件子类化的网友可以看看其具体实现的方法,主要是构造时提供了初始化资源、计算控件的尺寸和位置measure相关的处理,大家本次需要注意的是这个固定的Gird是从ViewGroup派生,没有实现onDraw,注意下面的onLayout方法,完整代码如下   public class FixedGridLayout extends ViewGroup {    int mCellWidth;    int mCellHeight;     public FixedGridLayout(Context context) {        super(context);    }     public FixedGridLayout(Context context, AttributeSet attrs) {        super(context, attrs);         TypedArray a = context.obtainStyledAttributes(                attrs, R.styleable.FixedGridLayout);        mCellWidth = a.getDimensionPixelSize(                R.styleable.FixedGridLayout_cellWidth, -1);        mCellHeight = a.getDimensionPixelSize(                R.styleable.FixedGridLayout_cellHeight, -1);        a.recycle();    }     public void setCellWidth(int px) {        […]

100% Secure Checkout

PayPal / MasterCard / Visa