The length of the formatted string. The ellipsis is displayed for the part exceeding the limit, which distinguishes Chinese characters from letters.

Source: Internet
Author: User

Because the display control of Android software requires that the length exceed a certain value to be truncated and added with a ellipsis, this method is written:

Package COM. eoeandroid. demo. testcode; import android. app. activity; import android. graphics. bitmap; import android. graphics. bitmapfactory; import android. graphics. matrix; import android. graphics. drawable. bitmapdrawable; import android. OS. bundle; import android. view. viewgroup. layoutparams; import android. widget. imageview; import android. widget. linearlayout; import android. widget. imageview. scaletype; public class bitmaptest extends activity {public void oncreate (bundle icicle) {super. oncreate (icicle); settitle ("eoeandroid Tutorial: Zoom and rotate image-by: iceskysl"); linearlayout linlayout = new linearlayout (this); // load the image to be operated, here is the eoeandroid logo image bitmap bitmaporg = bitmapfactory. decoderesource (getresources (), R. drawable. eoe_android); // get the width and height of the image. Int width = bitmaporg. getwidth (); int Height = bitmaporg. getheight (); // defines the width and height of the pre-converted image. Int newwidth = 200; int newheight = 200; // calculates the scaling rate, new dimensions except original dimensions float scalewidth = (float) newwidth)/width; float scaleheight = (float) newheight)/height; // create a matrix object for image operations. Matrix matrix = new matrix (); // scale the image action matrix. postscale (scalewidth, scaleheight); // rotate the image action matrix. postrotate (45); // create a new image bitmap resizedbitmap = bitmap. createbitmap (bitmaporg, 0, 0, width, height, matrix, true); // converts the bitmap created above to a drawable object so that it can be used in imageview, in imagebutton, bitmapdrawable BMI = new bitmapdrawable (resizedbitmap); // create an imageview = new imageview (this); // set the imageview image to the image imageview converted above. setimagedrawable (BMI); // center the image and display the imageview. setscaletype (scaletype. center); // Add the imageview to the layout template. addview (imageview, new linearlayout. layoutparams (layoutparams. fill_parent, layoutparams. fill_parent); // set setcontentview (linlayout) as the template of this activity );}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.