Android中怎么實(shí)現(xiàn)底圖局部加載移動(dòng)-創(chuàng)新互聯(lián)

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

站在用戶的角度思考問題,與客戶深入溝通,找到雁山網(wǎng)站設(shè)計(jì)與雁山網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名與空間、網(wǎng)頁空間、企業(yè)郵箱。業(yè)務(wù)覆蓋雁山地區(qū)。

具體如下:

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,前提,你圖片確實(shí)比屏幕大,如果不比屏幕大,下面注釋行修改一下即可。
  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)容,你們對(duì)Android中怎么實(shí)現(xiàn)底圖局部加載移動(dòng)有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。

分享文章:Android中怎么實(shí)現(xiàn)底圖局部加載移動(dòng)-創(chuàng)新互聯(lián)
標(biāo)題路徑:http://muchs.cn/article16/dpjegg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、App開發(fā)、關(guān)鍵詞優(yōu)化、軟件開發(fā)網(wǎng)站設(shè)計(jì)、用戶體驗(yàn)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管