簡體   English   中英

如何在一個屏幕上繪制多個位圖?

[英]How to draw multiple bitmaps on one screen?

我想知道如何在一個屏幕上繪制多個位圖。 我想要一個可以在多個位圖上滾動並查看每個位圖上的圖形的繪圖區域。 例如,我要滾動一個2x2的平鋪區域。 我在弄清楚在滾動時如何顯示2個或4個位圖的一部分時遇到了麻煩。

編輯:這就是它的樣子

在此處輸入圖片說明

我建議使用此模型為視圖組創建獲勝的實現:

public class MyLayout extends ViewGroup{
    public MyLayout(Context c, AttributeSet attr){
        super(c, attr);

        //Add this to be albe to draw by yourself
        this.setWillNotDraw(false);
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
    }

    @Override
    public onDraw(Canvas c){
        super.onDraw(c);

        //Do all your drawing in here
        //You can use canvas.drawBitmap etc...
    }
}

對於Android開發人員頁面上的自定義視圖組,這是一個很好的教程: http : //developer.android.com/reference/android/view/ViewGroup.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM