我正在使用Android Studio创建读书应用程序,但遇到了一些问题。
请参阅所附图片。
我有矩形X和Y位置,但是很大。
我希望所有设备都适合屏幕。
有人可以帮我吗?
谢谢。
这是自定义视图代码
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Rect rectangle;
Paint paint = new Paint();
paint.setColor(Color.GRAY);
File DBFile = new File(getContext().getExternalFilesDir(null), "Rectangles.db");
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(DBFile, null);
Cursor cur = db.rawQuery("SELECT * FROM ExportLine WHERE PageNo = 1", null);
cur.moveToFirst();
while(!cur.isAfterLast()) {
int lineX = cur.getInt(cur.getColumnIndex("X"));
int lineY = cur.getInt(cur.getColumnIndex("Y"));
int lineMaxX = cur.getInt(cur.getColumnIndex("XMax"));
int lineMaxY = cur.getInt(cur.getColumnIndex("YMax"));
rectangle = new Rect(lineX , lineY, lineMaxX, lineMaxY);
canvas.drawRect(rectangle, paint);
cur.moveToNext();
}
}
我创建的第一张图片
我想要最后一张图片
我所有坐标