我有一个应用程序,我正在为学生座位表创建。我希望有一个拖放某些人物图标的背景,并且它在我的Galaxy S上工作正常。但是,在Galaxy Tab上,背景比显示屏缩小得多(见图)。
似乎无论位图有多大,在Galaxy Tab仿真器上它的大小都会缩小到大约2/3。当我使用替代资源作为位图时,它保持大约屏幕大小的2/3。
我的代码如下:
public DrawView(Context context, Long mClassID) {
super(context);
setFocusable(true); //necessary for getting the touch events
mDbHelper = new gradeBookDbAdapter(context);
mDbHelper.open();
c = mDbHelper.fetchAllStudentsClassSeating(mClassID);
int count = 0;
if (c.getCount() > 0){
c.moveToFirst();
do {
String name = c.getString(c.getColumnIndexOrThrow(gradeBookDbAdapter.KEY_NAME));
studentId = c.getInt(c.getColumnIndexOrThrow(gradeBookDbAdapter.KEY_ROWID));
Point point = new Point();
int X = c.getInt(c.getColumnIndexOrThrow(gradeBookDbAdapter.KEY_X));
int Y = c.getInt(c.getColumnIndexOrThrow(gradeBookDbAdapter.KEY_Y));
point.x = (X <= 0)? (10 + count*initsize) : X;
point.y = (Y <= 0)? 10 : Y;
studentDesks.add(new StudentDesk(context, c.getCount(), studentId, point, name));
count++;
} while (c.moveToNext());
}
c.close();
// import the background for the classroom
bkg = BitmapFactory.decodeResource(context.getResources(), R.drawable.classroom);
}
@Override protected void onDraw(Canvas canvas) {
canvas.drawBitmap(bkg,0,0,null);
//draw the desks on the canvas
for (int index = 0; index < studentDesks.size(); index++ ) {
StudentDesk desk = studentDesks.get(index);
canvas.drawBitmap(desk.getBitmap(), desk.getX(), desk.getY(), null);
}
}
// events when touching the screen
public boolean onTouchEvent(MotionEvent event) {
int eventaction = event.getAction();
<snipped>
}
那么我应该做些什么来让背景(bkg)扩展为Galaxy Tab?当我读它时它已经是600x1200,所以为什么它会缩小到它的大小以下 屏幕?