Use of Androidimageview

Source: Internet
Author: User

Configuration of XML Files <imageview     android:id= "@+id/imageviewid"      Android:layout_width= "100DP"     android:layout_height= "100DP"      android:src= "@drawable/a0"     android:background= "#ff0000"     android: Scaletype= "center"     /><imageview     android:id= "@+id/ ImageView2 "   android:layout_width=" 100DP "    android:layout_height=" 100DP "     android:background= "#00ff00"     android:src= "@drawable/ic_launcher "    android:scaletype="     />     "Fitcenter"     //mainactivity file     public class MainActivity  extends activity {private imageview imageview;private imageview imageview1;      @Override &NBsp;   protected void oncreate (bundle savedinstancestate)  {         super.oncreate (savedinstancestate);         setcontentview (R.layout.activity_main);         imageview= ( ImageView) Findviewbyid (R.ID.IMAGEVIEWID);       //  Imageview.setimageresource (R.DRAWABLE.A0);         imageview1= ( ImageView) Findviewbyid (R.ID.IMAGEVIEW2);         imageview.setscaletype (Scaletype.center);         imageview1.setscaletype (ScaleType.FIT_ CENTER);            }                 //description of the ScaleType property    //  imageview's scaletype determines what the image looks like when it is displayed on the view, such as the scaleand show the picture///The whole or part of the piece, etc. The way to set up includes://1.  defining android:scaletype= "CENTER"//2.  in Layout xml or calling Imageview.setscaletype in code ( ImageView.ScaleType.CENTER);

1. Setscaletype (ImageView.ScaleType.CENTER);

Centered on the original size of the picture, when the picture is longer/wider than the length/width of the view, the center portion of the image is displayed

650) this.width=650; "src=" Http://hi.csdn.net/attachment/201110/30/0_1319980238S0ht.gif "style=" border:none; Font-family:arial;font-size:14px;line-height:26px;white-space:normal;background-color:rgb (255,255,255); "/> 650) this.width=650; "src=" Http://hi.csdn.net/attachment/201110/30/0_1319980257h8NT.gif "style=" bo Rder:none;font-family:arial;font-size:14px;line-height:26px;white-space:normal;background-color:rgb ( 255,255,255); "/>

2. Setscaletype (ImageView.ScaleType.CENTER_CROP);

Proportionally enlarges the size of the image so that the image is long (wide) equal to or greater than the length (width) of the view

650) this.width=650; "src=" Http://hi.csdn.net/attachment/201110/30/0_1319980210oDm8.gif "style=" border:none; "/ > 650) this.width=650; "src=" http://hi.csdn.net/attachment/201110/30/0_13199802252Hvf.gif "style=" border: none; "/>


3. Setscaletype (ImageView.ScaleType.CENTER_INSIDE);

Center the contents of the picture in full, by scaling it down or the original size to make the picture long/wide equal to or less than the length/width of the view

650) this.width=650; "src=" Http://hi.csdn.net/attachment/201110/30/0_1319980180mJsK.gif "style=" border:none; "/ > 650) this.width=650; "src=" http://hi.csdn.net/attachment/201110/30/0_1319980194fb0b.gif "style=" border: none; "/>


4. Setscaletype (ImageView.ScaleType.FIT_CENTER);

Enlarges/shrinks the image to the width of the view, centered on the display

650) this.width=650; "src=" Http://hi.csdn.net/attachment/201110/30/0_1319980150BcCh.gif "style=" border:none; "/ > 650) this.width=650; "src=" http://hi.csdn.net/attachment/201110/30/0_13199801347auQ.gif "style=" border: none; "/>


5. Fit_start, fit_end in the picture zoom effect and fit_center, just show the location of different, Fit_start is placed on the top, Fit_center Center, fit_end at the bottom.

There is no example to show here.


6. Fit_xy

Do not scale the picture proportionally, the goal is to fill the picture with the entire view.

650) this.width=650; "src=" Http://hi.csdn.net/attachment/201110/30/0_1319980055JRlc.gif "height=" 402 "width=" 244 " Style= "border:none;width:244px;height:402px;"/> 650) this.width=650; "Src=" http://hi.csdn.net/attachment /201110/30/0_1319980073vf07.gif "height=" 402 "width=" 243 "style=" border:none;width:243px;height:402px; "/>

(citation csdn) http://blog.csdn.net/larryl2003/article/details/6919513



Generally used is fit_center .

This article is from the "Java White Battlefield" blog, be sure to keep this source http://8023java.blog.51cto.com/10117207/1658647

Use of Androidimageview

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.