KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Many posts are found according to the topic "screenshot a TextView into a Bitmap". Well, the difference to my problem is, that first the view is drawn on the display (with all layouting and measuring work already done) and then drawn into a Canvas connected to a Bitmap. I just want to create a TextView from scratch without ever being shown on the display which is rendered into a Bitmap. This one is the basis configuration which is already workin. A click on the TextView draws itself into a Bitmap and sets it to an ImageView. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#fff"> <TextView android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="The Quick Brown Fox Jumps Over The Lazy Dog." android:textSize="20dip" android:background="#abcdef" android:textColor="#000" android:padding="10dip" android:layout_margin="10dip" /> <ImageView android:id="@+id/iv" android:layout_width="449px" android:layout_height="47px" android:background="#56789a" android:layout_margin="10dip" /> </LinearLayout> @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); findViewById(R.id.tv).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Bitmap bmp = Bitmap.createBitmap(449, 47, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bmp); v.draw(canvas); ImageView iv = (ImageView) findViewById(R.id.iv); iv.setImageBitmap(bmp); } }); } Now comes the problematic part. I will create a TextView in Java an
Tags (comma-separated)
Save Edits
Cancel