今天就跟大家聊聊有關(guān)Android中怎么實現(xiàn)底圖局部加載移動,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

創(chuàng)新互聯(lián)建站主要從事網(wǎng)站建設(shè)、成都做網(wǎng)站、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)無極,十余年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18980820575
具體如下:
public class MapMgr {
public static MapMgr mapMgr = null;
private int map_num = 28;
private int b_x = 0;
private int b_y = 0;
private int width = 0;
private int height = 0;
private Bitmap bmpView = null;
//create by danielinbiti,前提,你圖片確實比屏幕大,如果不比屏幕大,下面注釋行修改一下即可。
public static void init(int width,int height){
if(mapMgr==null){
mapMgr = new MapMgr(width,height);
}
}
public static MapMgr getInstance(){
return mapMgr;
}
public MapMgr(int width,int height){
this.width = width;
this.height = height;
Bitmap bmp = PicMgr.getInstance().getBackGroundBitmap();
b_x = (bmp.getWidth()-width)/2;//保證圖片比屏幕大
b_y = (bmp.getHeight()-height)/2;
bmpView = Bitmap.createBitmap(bmp, b_x, b_y, width, height);
}
public void logic(){
}
public void mapDown(){
Bitmap bmp = PicMgr.getInstance().getBackGroundBitmap();
if(b_y+height<bmp.getHeight()){
b_y = b_y + bmp.getHeight()/map_num;
if(b_y+height>bmp.getHeight()){
b_y = bmp.getHeight() - height;
}
}
bmpView = Bitmap.createBitmap(bmp, b_x, b_y, width, height);
}
public void mapUp(){
Bitmap bmp = PicMgr.getInstance().getBackGroundBitmap();
if(b_y>0){
b_y = b_y - bmp.getHeight()/map_num;
if(b_y<0){
b_y = 0;
}
}
bmpView = Bitmap.createBitmap(bmp, b_x, b_y, width, height);
}
public void mapLeft(){
Bitmap bmp = PicMgr.getInstance().getBackGroundBitmap();
if(b_x>0){
b_x = b_x - bmp.getWidth()/map_num;
if(b_x<0){
b_x = 0;
}
}
bmpView = Bitmap.createBitmap(bmp, b_x, b_y, width, height);
}
public void mapRight(){
Bitmap bmp = PicMgr.getInstance().getBackGroundBitmap();
if(b_x+width<bmp.getWidth()){
b_x = b_x + bmp.getWidth()/map_num;
if(b_x+width>bmp.getWidth()){
b_x = bmp.getHeight() - width;
}
}
bmpView = Bitmap.createBitmap(bmp, b_x, b_y, width, height);
}
public void draw(Canvas canvas){
Paint paint = new Paint();
if(bmpView!=null){
canvas.drawBitmap(bmpView,0, 0, paint);
}
}
}調(diào)用
public void onKeyDownDeal(int keyCode){
if(keyCode==KeyEvent.KEYCODE_DPAD_UP){
MapMgr.getInstance().mapUp();
}else if(keyCode==KeyEvent.KEYCODE_DPAD_DOWN){
MapMgr.getInstance().mapDown();
}else if(keyCode==KeyEvent.KEYCODE_DPAD_LEFT){
MapMgr.getInstance().mapLeft();
}else if(keyCode==KeyEvent.KEYCODE_DPAD_RIGHT){
MapMgr.getInstance().mapRight();
}
}看完上述內(nèi)容,你們對Android中怎么實現(xiàn)底圖局部加載移動有進(jìn)一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。
分享名稱:Android中怎么實現(xiàn)底圖局部加載移動
本文地址:http://www.js-pz168.com/article32/pojdsc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、品牌網(wǎng)站設(shè)計、建站公司、網(wǎng)站維護(hù)、定制開發(fā)、網(wǎng)站策劃
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)