Android Development Note ___ Image view

Source: Internet
Author: User

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "android:orientation=" vertical "&    Gt <imageview android:id= "@+id/iv_scale" android:layout_width= "Match_parent" android:layout_height= "3 00DP "android:layout_margintop=" 10DP "android:src=" @drawable/apple1 "/> <linearlayout androi D:layout_width= "Match_parent" android:layout_height= "wrap_content" android:layout_margintop= "10DP" an droid:orientation= "Horizontal" > <button android:id= "@+id/btn_fitcenter" Android:layout_ Width= "0DP" android:layout_height= "Wrap_content" android:layout_weight= "1" android:text= " Fitcenter "android:textcolor=" #000000 "android:textsize=" 11sp "/> <button an Droid:id= "@+id/btn_centercroP "android:layout_width=" 0DP "android:layout_height=" Wrap_content "android:layout_weight=        "1" android:text= "Centercrop" android:textcolor= "#000000" android:textsize= "11sp"/> <button android:id= "@+id/btn_centerinside" android:layout_width= "0DP" Android:la yout_height= "Wrap_content" android:layout_weight= "1" android:text= "Centerinside" Android: Textcolor= "#000000" android:textsize= "11sp"/> </LinearLayout> <linearlayout android:l Ayout_width= "Match_parent" android:layout_height= "wrap_content" android:layout_margintop= "10DP" Andro id:orientation= "Horizontal" > <button android:id= "@+id/btn_center" android:layout_width= "0DP" android:layout_height= "Wrap_content" android:layout_weight= "1" android:text= "center "Android:texTcolor= "#000000" android:textsize= "11sp"/> <button android:id= "@+id/btn_fitxy"            Android:layout_width= "0DP" android:layout_height= "Wrap_content" android:layout_weight= "1" android:text= "Fitxy" android:textcolor= "#000000" android:textsize= "11sp"/> <butto n android:id= "@+id/btn_fitstart" android:layout_width= "0DP" android:layout_height= "Wrap_c            Ontent "android:layout_weight=" 1 "android:text=" Fitstart "android:textcolor=" #000000 " Android:textsize= "11sp"/> <button android:id= "@+id/btn_fitend" Android:layout_ Width= "0DP" android:layout_height= "Wrap_content" android:layout_weight= "1" android:text= " Fitend "android:textcolor=" #000000 "android:textsize=" 11sp "/> </LinearLayout> <bu Tton Android:layoUt_width= "Match_parent" android:layout_height= "wrap_content" android:text= "screenshot" android:id= "@+id/btn_2 .3.3.2 "/></linearlayout>

Java

 PackageCom.example.alimjan.hello_world;ImportAndroid.content.Context;Importandroid.content.Intent;ImportAndroid.os.Bundle;Importandroid.support.v7.app.AppCompatActivity;ImportAndroid.view.View;ImportAndroid.widget.Button;ImportAndroid.widget.ImageView;/*** Created by Alimjan on 6/30/2017.*/ Public classClass__2_3_3extendsAppcompatactivityImplementsView.onclicklistener {PrivateImageView Iv_scale; PrivateButton Btn_2_3_3_2; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.code_2_3_3); Iv_scale=(ImageView) Findviewbyid (R.id.iv_scale); Findviewbyid (R.id.btn_center). Setonclicklistener ( This); Findviewbyid (R.id.btn_fitcenter). Setonclicklistener ( This); Findviewbyid (R.id.btn_centercrop). Setonclicklistener ( This); Findviewbyid (r.id.btn_centerinside). Setonclicklistener ( This); Findviewbyid (R.ID.BTN_FITXY). Setonclicklistener ( This); Findviewbyid (R.id.btn_fitstart). Setonclicklistener ( This); Findviewbyid (r.id.btn_fitend). Setonclicklistener ( This); Btn_2_3_3_2=(Button) Findviewbyid (r.id.btn_2_3_3_2); Btn_2_3_3_2.setonclicklistener ( This); } @Override Public voidOnClick (View v) {if(V.getid () = =r.id.btn_center)        {Iv_scale.setscaletype (ImageView.ScaleType.CENTER); } Else if(V.getid () = =r.id.btn_fitcenter)        {Iv_scale.setscaletype (ImageView.ScaleType.FIT_CENTER); } Else if(V.getid () = =R.id.btn_centercrop)        {Iv_scale.setscaletype (ImageView.ScaleType.CENTER_CROP); } Else if(V.getid () = =r.id.btn_centerinside)        {Iv_scale.setscaletype (ImageView.ScaleType.CENTER_INSIDE); } Else if(V.getid () = =r.id.btn_fitxy)        {Iv_scale.setscaletype (ImageView.ScaleType.FIT_XY); } Else if(V.getid () = =R.id.btn_fitstart)        {Iv_scale.setscaletype (ImageView.ScaleType.FIT_START); } Else if(V.getid () = =r.id.btn_fitend)        {Iv_scale.setscaletype (ImageView.ScaleType.FIT_END); } Else if(V.getid () = =r.id.btn_2_3_3_2) {class__2_3_3_2.starthome (class__2_3_3). This); }    }     Public Static voidstarthome (Context mcontext) {Intent Intent=NewIntent (Mcontext, Class__2_3_3.class);    Mcontext.startactivity (Intent); }}

Android Development Note ___ Image view

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.