Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting a TextView->Bitmap->ImageView, and nothing's showing up
    primarykey
    data
    text
    <p>I started a test project just to get this down. No changes to main.xml. I want to create a widget-sized ImageView (80x100) that contains a Bitmap converted from a TextView. Yes, that sounds very roundabout but this is just for testing; in the end I want the ImageView to have a background image and multiple TextViews. I'm not sure exactly what I'm doing wrong, but nothing is being pushed to the screen.</p> <p>Is it a problem with declaring the TextView/ImageView and passing it "this" in the constructor? Is it a problem with my layoutParams? Here is the code:</p> <pre><code>package com.doaf.testproject; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.Canvas; import android.os.Bundle; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; public class TestProject extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(80, 100); tv.setLayoutParams(layoutParams); tv.setText("testing 1 2 3"); tv.setTextColor(0xFFFFFF); tv.setBackgroundColor(0x555555); Bitmap testB; testB = loadBitmapFromView(tv); ImageView iv = new ImageView(this); iv.setLayoutParams(layoutParams); iv.setBackgroundColor(0x555555); iv.setImageBitmap(testB); setContentView(iv); } public static Bitmap loadBitmapFromView(View v) { Bitmap b = Bitmap.createBitmap(80, 100, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); v.layout(0, 0, 80, 100); v.draw(c); return b; } } </code></pre> <p>Thanks for any help you can provide. I'm relatively new to Android, and pretty lost with this one.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload