textview - Android Text to Image issue -


The

I code for text image in Android application and it changed the text to successfully image and a local place The problem I am facing in the SD card is that it is not converting the full text into an image. Here is the text I am supplying TextView "t ashdf asdhfj sdhkfh SHD jshd hsdhfsdjkhfksdjfhsdlhfksldhfklh shdkfjhsdkj hfsdjk kdjhfsk djhfskldh shdjkfhk is sjhdfkh." Here's how changes to the image enter image description here

here is my code

  RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams (LayoutParams.MATCH_PARENT, 60); Tv.setLayoutParams (layoutParams); tv.setText ( "This is not ashdf asdhfj sdhkfh SHD jshd hsdhfsdjkhfksdjfhsdlhfksldhfklh shdkfjhsdkj hfsdjk kdjhfsk djhfskldh shdjkfhk sjhdfkh"); Tv.setTextColor (Color.BLACK); Tv.setBackgroundColor (Color.WHITE); Bitmap test b; Timer = new timer (); Timer Schedulhe (new tickerTask (), 1000,25); testB = Bitmap.createBitmap (. tv.getText () Length (), 20, Bitmap.Config.ARGB_8888); Canvas C = new canvas (test b); TV. Layout (0, 0, 800, 30); Tv.draw (c); Iv = (ImageView) findViewById (R.id.menuIcon); X = 40; Iv.setPadding (X, 0, 0, 0); Iv.setLayoutParams (layoutParams); Iv.setBackgroundColor (Color.GREEN); Iv.setImageBitmap (testB); Iv.setDrawingCacheEnabled (true); Bitmap drawable = (bitmaprwable) iv.getDrawable (); Bitmap bitmap = drawablegatebitmap (); // bitmap bitmap = test b; File sdCardDirectory = Environment.getExternalStorageDirectory (); File Image = New File (SDCDD Directory, "test.png"); Boolean success = false; // Encrypt file as a PNG image FileOutputStream Outstream; {Outstream = Try New FileOutputStream (Image); Bitmap Commerce (bitmap.compress format.png, 100, outstream); / * 100 to keep the full quality of the image * / outstream.flush (); OutStream.close (); Success = true; } Hold (FileNotFoundException e) {e.printStackTrace (); } Hold (IOException e) {e.printStackTrace (); } If (success) {Toast. GetApplicationContext, "Image saved with success" + TV. Tags (). Length (), toast. LNNHT_Leng) Show (); } Else {toast.makeText (getApplicationContext), "error during image saving", toast .LENGTH_LONG). Show (); }    

I think the problem is that your textView Your method is to convert the drawing area of ​​your view to bitmap. If any part of your text is hidden, then the drawing is not really drawn in the area. Why do not you get the text from TextView and write it in the canvas? You can use this method:

  canvas.drawText ();   

Sample code:

  Paint paint = new paint (); Paint.setColor (Color.RED); Paint.setStyle (Paint.Style.FILL); Paint.setAntiAlias ​​(right); Paint.setTextSize (20); Canvas.drawText ("Hello Android! Fill ...", 50, 230, Paint);    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -