Reputation: 719
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);
Upvotes: 1
Views: 2426
Reputation: 5356
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.
Upvotes: 1