Example of standard Media application skin on Bold 9000
removed dead ImageShack link - sliced Media application
removed dead ImageShack link - Sliced images
Use extention of ButtonField to map images with buttons:
class BitmapButtonField extends ButtonField {
Bitmap mNormal;
Bitmap mFocused;
Bitmap mActive;
int mWidth;
int mHeight;
public BitmapButtonField(Bitmap normal, Bitmap focused,
Bitmap active) {
super(CONSUME_CLICK);
mNormal = normal;
mFocused = focused;
mActive = active;
mWidth = mNormal.getWidth();
mHeight = mNormal.getHeight();
setMargin(0, 0, 0, 0);
setPadding(0, 0, 0, 0);
setBorder(BorderFactory
.createSimpleBorder(new XYEdges(0, 0, 0, 0)));
setBorder(VISUAL_STATE_ACTIVE, BorderFactory
.createSimpleBorder(new XYEdges(0, 0, 0, 0)));
}
protected void paint(Graphics graphics) {
Bitmap bitmap = null;
switch (getVisualState()) {
case VISUAL_STATE_NORMAL:
bitmap = mNormal;
break;
case VISUAL_STATE_FOCUS:
bitmap = mFocused;
break;
case VISUAL_STATE_ACTIVE:
bitmap = mActive;
break;
default:
bitmap = mNormal;
}
graphics.drawBitmap(0, 0, bitmap.getWidth(), bitmap.getHeight(),
bitmap, 0, 0);
}
public int getPreferredWidth() {
return mWidth;
}
public int getPreferredHeight() {
return mHeight;
}
protected void layout(int width, int height) {
setExtent(mWidth, mHeight);
}
}
- put HorizontalFieldManagers inside VerticalFieldManagers and vice versa
- use different images for normal, focused and active states
- if you need a custom shaped buttons, you can draw them over in manager paint() method override, after super.paint()
Rest part of code:
class Scr extends MainScreen implements FieldChangeListener {
Bitmap mBmpHeader = Bitmap.getBitmapResource("header.png");
Bitmap mBmpCover = Bitmap.getBitmapResource("cover.png");
Bitmap mBmpTitle = Bitmap.getBitmapResource("title.png");
Bitmap mBmpTimeline = Bitmap.getBitmapResource("timeline.png");
Bitmap mBmpLeftside = Bitmap.getBitmapResource("leftside.png");
Bitmap mBmpPrevNrm = Bitmap.getBitmapResource("btn_prev_normal.png");
Bitmap mBmpPlayNrm = Bitmap.getBitmapResource("btn_play_normal.png");
Bitmap mBmpPauseNrm = Bitmap.getBitmapResource("btn_pause_normal.png");
Bitmap mBmpStopNrm = Bitmap.getBitmapResource("btn_stop_normal.png");
Bitmap mBmpNextNrm = Bitmap.getBitmapResource("btn_next_normal.png");
Bitmap mBmpPrevFcs = Bitmap.getBitmapResource("btn_prev_focused.png");
Bitmap mBmpPlayFcs = Bitmap.getBitmapResource("btn_play_focused.png");
Bitmap mBmpPauseFcs = Bitmap.getBitmapResource("btn_pause_focused.png");
Bitmap mBmpStopFcs = Bitmap.getBitmapResource("btn_stop_focused.png");
Bitmap mBmpNextFcs = Bitmap.getBitmapResource("btn_next_focused.png");
Bitmap mBmpRightside = Bitmap.getBitmapResource("rightside.png");
VerticalFieldManager mMainManager;
HorizontalFieldManager mHeaderManager;
HorizontalFieldManager mCoverManager;
HorizontalFieldManager mTitleManager;
HorizontalFieldManager mTimelineManager;
HorizontalFieldManager mToolbarManager;
BitmapField mHeader;
BitmapField mCover;
BitmapField mTitle;
BitmapField mTimeline;
BitmapField mLeftside;
BitmapField mRightside;
BitmapButtonField mBtnPrev;
BitmapButtonField mBtnPlay;
BitmapButtonField mBtnPause;
BitmapButtonField mBtnStop;
BitmapButtonField mBtnNext;
public Scr() {
add(mMainManager = new VerticalFieldManager());
addHeader();
addCover();
addTitle();
addTimeline();
addToolbar();
}
private void addHeader() {
mMainManager.add(mHeaderManager = new HorizontalFieldManager());
mHeaderManager.add(mHeader = new BitmapField(mBmpHeader));
}
private void addCover() {
mMainManager.add(mCoverManager = new HorizontalFieldManager());
mCoverManager.add(mCover = new BitmapField(mBmpCover));
}
private void addTitle() {
mMainManager.add(mTitleManager = new HorizontalFieldManager());
mTitleManager.add(mTitle = new BitmapField(mBmpTitle));
}
private void addTimeline() {
mMainManager.add(mTimelineManager = new HorizontalFieldManager());
mTimelineManager.add(mTimeline = new BitmapField(mBmpTimeline));
}
private void addToolbar() {
mMainManager.add(mToolbarManager = new HorizontalFieldManager());
mToolbarManager.add(mLeftside = new BitmapField(mBmpLeftside));
mToolbarManager.add(mBtnPrev = new BitmapButtonField(mBmpPrevNrm,
mBmpPrevFcs, mBmpPrevFcs));
mToolbarManager.add(mBtnPlay = new BitmapButtonField(mBmpPlayNrm,
mBmpPlayFcs, mBmpPlayFcs));
mBtnPlay.setChangeListener(this);
mBtnPause = new BitmapButtonField(mBmpPauseNrm, mBmpPauseFcs,
mBmpPauseFcs);
mBtnPause.setChangeListener(this);
mToolbarManager.add(mBtnStop = new BitmapButtonField(mBmpStopNrm,
mBmpStopFcs, mBmpStopFcs));
mToolbarManager.add(mBtnNext = new BitmapButtonField(mBmpNextNrm,
mBmpNextFcs, mBmpNextFcs));
mToolbarManager.add(mRightside = new BitmapField(mBmpRightside));
}
public void fieldChanged(Field field, int context) {
if (mBtnPlay == field)
play();
else if (mBtnPause == field)
pause();
}
private void pause() {
mToolbarManager.replace(mBtnPause, mBtnPlay);
}
private void play() {
mToolbarManager.replace(mBtnPlay, mBtnPause);
}
}