ImageView不显示在位图中

时间:2011-12-26 06:26:57

标签: android canvas bitmap

...
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mViewer = getLayoutInflater().inflate(R.layout.rcviewer, null);
    setContentView(mViewer);

    mViewerTitle = (TextView)findViewById(R.id.viewer_title);
    mViewerBody = (TextView)findViewById(R.id.viewer_body);
    mViewerPage= (TextView)findViewById(R.id.viewer_page);
    mImgBookmark = (ImageView)findViewById(R.id.viewer_bookmark);
    mImgBookmark.setVisibility(View.GONE);
}
...

public Bitmap getCurrentPage() {
    Bitmap tmpBitmap = Bitmap.createBitmap(mDisplay.getWidth(), mDisplay.getHeight(), Bitmap.Config.ARGB_4444);
    tmpBitmap.eraseColor(0xffffffff);

    if (isBookmarked()) {
        mImgBookmark.setVisibility(View.VISIBLE);
    }
    else {
        mImgBookmark.setVisibility(View.GONE);
    }

    mViewerTitle.setText(mPage.getTitle());
    mViewerBody.setText(mPage.getContent());
    mViewerPage.setText(mPage.getPage());

    Canvas canvas = new Canvas(tmpBitmap);
    mViewer.draw(canvas);

    return tmpBitmap;
}

虽然'isBookmarked()'为真,但'mImgBookmark'不会显示在tmpBitmap中。 mViewerTitle,mViewerBody,mViewerPage显示在tmpBitmap中。

我想在tmpBitmap中显示'mImgBookmark'图像。 我不知道该怎么办。 我该怎么办 ?

谢谢。

1 个答案:

答案 0 :(得分:0)

 mImgBookmark = (ImageView)findViewById(R.id.viewer_bookmark);
    mImgBookmark.setVisibility(View.GONE);

//Sets a Bitmap as the content of this ImageView.
mImgBookmark.setImageBitmap(getCurrentPage())