Android text to image -


I want to convert the image to an image in a string and display it in a ImageView Besides, I want to get the dimensions of the image created at run time for further use. Here's what I've done and used from the search.

  tv = new text view (this); RelativeLayout.LayoutParams LayoutThird = New Relative Layout LayoutParam (layout paramaMATHPARNR, 60); Tv.setLayoutParams (layoutParams); Tv.setText ("Some text may be as long as possible"); Tv.setTextColor (Color.BLACK); Tv.setBackgroundColor (Color.WHITE); Bitmap test b; Timer = new timer (); Timer Schedulhe (new tickerTask (), 1000,25); TestB = Bitmap.SetByTemap (600, 20, Bitmap config.argb_8888); Canvas C = new canvas (test b); TV. Layout (0, 0, 380, 100); Tv.draw (c); Iv = (ImageView) findViewById (R.id.menuIcon); Iv.setLayoutParams (layoutParams); Iv.setBackgroundColor (Color.GREEN); Iv.setImageBitmap (testB);   

Problems: The parameters are not working as set in the code. The whole text is not shown after converting the image.

I believe this is picking up the whole screen because you do not have any containers such as Linear layout that includes an image view with one layout barriers, so the image screen spreads to fill the available screen. Try it out:

  @Orride Creates a Public Zero (Bundle Saved Instantstate) {SuperConnected InstantState}; SetContentView (R.layout.main); TextView TV = new textview (this); LinearLayout.LayoutParamsLatestPuram = New LinearLayout.LayoutParams (80, 100); Tv.setLayoutParams (layoutParams); Tv.setText ("Test 1 2 3"); Tv.setTextColor (Color.BLACK); Tv.setBackgroundColor (Color.TRANSPARENT); Bitmap test b; TestB = Bitmap.SetByTemap (80, 100, bitmap config.argb_8888); Canvas C = new canvas (test b); TV. Layout (0, 0, 80, 100); Tv.draw (c); ImageView iv = (ImageView) findViewById (R.id.menuIcon); Iv.setLayoutParams (layoutParams); Iv.setBackgroundColor (Color.GRAY); Iv.setImageBitmap (testB); Iv.setMaxHeight (80); Iv.setMaxWidth (80); }   

and your main. In the Xml file:

  & lt; LinearLayout xmlns: android = "http://schemas.android.com/apk/ Res / android" android: orientation = "vertical" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" & gt; & Lt; ImageView Android: id = "@ + id / menuIcon" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" /> & Lt; / LinearLayout & gt;    

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 -