Create Image from imageview and textview?

こ雲淡風輕ζ 提交于 2019-12-06 07:30:16
Lalit Poptani

Yes there is a way to do this,

You can create an Bitmap of any view using buildDrawingCache() and getDrawingCache()

TextView tv = (TextView)findViewById(R.id.textview);
tv.buildDrawingCache();
ImageView img = (ImageView)findViewById(R.id.imageview);
img.setImageBitmap(tv.getDrawingCache());

You can also check this answer for further reference.

You can also use TextView instead of ImageView and set image as background to TextView.And after you can also add text to TextView. Save the all the texts to somewhere and on showing again Gallery again use the texts you save with the images.

try this:

 TextView tv1 = new TextView(this);
 LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(80, 100);
    tv1.setLayoutParams(layoutParams);
    tv1.setText("testing 1 2 3");
    tv1.setTextColor(Color.BLACK);
    tv1.setBackgroundColor(Color.TRANSPARENT);

add to it on button click with your layout-->your layout reference and then

.addview(tv1);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!