1

Is it possible to create a image from a textview and imageview and set the appicon to the image?

Something like this:

TextView tv = new TextView(getBaseContext());
    tv.setText("Hello");

    tv.buildDrawingCache();
    ImageView img = new ImageView(getBaseContext());
    img.setImageBitmap(tv.getDrawingCache());

    img.buildDrawingCache();
    Bitmap bmap = img.getDrawingCache();

    Drawable d = new BitmapDrawable(getResources(), bmap);

    getActionBar().setIcon(d);
hugocarlmartin
  • 719
  • 1
  • 8
  • 25

1 Answers1

1

Why don't you use a Canvas ? Convert String text to Bitmap

You can draw texts and bitmap and then set the icon of the actionbar. You can get the Bitmap of a ImageView with :

Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();

And then draw the text and the bitmap in the canvas and generate a Bitmap from that. Using drawing cache is possible but not advised.

As for your question, you should try your method before asking if it will work here.

Community
  • 1
  • 1
NitroG42
  • 5,336
  • 2
  • 28
  • 32