设置Manager的高度及背景图片,思路:重写Manager里面的sublayout方法,加上setExtent(width, h); 重写paintBackground方法设置背景图片。代码如下,调用的时候传入参数就可以了...
CustomVerticalFieldManager.java
public class CustomVerticalFieldManager extends VerticalFieldManager{
private int h;
private Bitmap _bitmap;
public CustomVerticalFieldManager (long style, int h, Bitmap _bitmap,){
super(style);
this.h = h;
this._bitmap = _bitmap;
}
protected void sublayout(int width, int height) {
int numberOfFields = getFieldCount();
for (int i = 0; i < numberOfFields; ++i) {
layoutChild(getField(i), width, height);
setPositionChild(getField(i), 0, 0);
}
setExtent(width, h);
}
protected void paintBackground(Graphics graphics) {
if(_bitmap != null){
graphics.drawBitmap(0, 0, _bitmap.getWidth(), _bitmap.getHeight(), _bitmap, 0, 0);
super.paint(graphics);
}
}
}