1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:orientation="vertical">
  6.  
  7. <ImageView
  8. android:id="@+id/iv_scale"
  9. android:layout_width="match_parent"
  10. android:layout_height="300dp"
  11. android:layout_marginTop="10dp"
  12. android:src="@drawable/apple1" />
  13.  
  14. <LinearLayout
  15. android:layout_width="match_parent"
  16. android:layout_height="wrap_content"
  17. android:layout_marginTop="10dp"
  18. android:orientation="horizontal">
  19.  
  20. <Button
  21. android:id="@+id/btn_fitCenter"
  22. android:layout_width="0dp"
  23. android:layout_height="wrap_content"
  24. android:layout_weight="1"
  25. android:text="fitCenter"
  26. android:textColor="#000000"
  27. android:textSize="11sp" />
  28.  
  29. <Button
  30. android:id="@+id/btn_centerCrop"
  31. android:layout_width="0dp"
  32. android:layout_height="wrap_content"
  33. android:layout_weight="1"
  34. android:text="centerCrop"
  35. android:textColor="#000000"
  36. android:textSize="11sp" />
  37.  
  38. <Button
  39. android:id="@+id/btn_centerInside"
  40. android:layout_width="0dp"
  41. android:layout_height="wrap_content"
  42. android:layout_weight="1"
  43. android:text="centerInside"
  44. android:textColor="#000000"
  45. android:textSize="11sp" />
  46.  
  47. </LinearLayout>
  48.  
  49. <LinearLayout
  50. android:layout_width="match_parent"
  51. android:layout_height="wrap_content"
  52. android:layout_marginTop="10dp"
  53. android:orientation="horizontal">
  54.  
  55. <Button
  56. android:id="@+id/btn_center"
  57. android:layout_width="0dp"
  58. android:layout_height="wrap_content"
  59. android:layout_weight="1"
  60. android:text="center"
  61. android:textColor="#000000"
  62. android:textSize="11sp" />
  63.  
  64. <Button
  65. android:id="@+id/btn_fitXY"
  66. android:layout_width="0dp"
  67. android:layout_height="wrap_content"
  68. android:layout_weight="1"
  69. android:text="fitXY"
  70. android:textColor="#000000"
  71. android:textSize="11sp" />
  72.  
  73. <Button
  74. android:id="@+id/btn_fitStart"
  75. android:layout_width="0dp"
  76. android:layout_height="wrap_content"
  77. android:layout_weight="1"
  78. android:text="fitStart"
  79. android:textColor="#000000"
  80. android:textSize="11sp" />
  81.  
  82. <Button
  83. android:id="@+id/btn_fitEnd"
  84. android:layout_width="0dp"
  85. android:layout_height="wrap_content"
  86. android:layout_weight="1"
  87. android:text="fitEnd"
  88. android:textColor="#000000"
  89. android:textSize="11sp" />
  90.  
  91. </LinearLayout>
  92.  
  93. <Button
  94. android:layout_width="match_parent"
  95. android:layout_height="wrap_content"
  96. android:text="截屏"
  97. android:id="@+id/btn_2.3.3.2"/>
  98.  
  99. </LinearLayout>

  Java

  1. package com.example.alimjan.hello_world;
  2.  
  3. import android.content.Context;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.support.v7.app.AppCompatActivity;
  7. import android.view.View;
  8. import android.widget.Button;
  9. import android.widget.ImageView;
  10.  
  11. /**
  12. * Created by alimjan on 6/30/2017.
  13. */
  14.  
  15. public class class__2_3_3 extends AppCompatActivity implements View.OnClickListener {
  16. private ImageView iv_scale;
  17. private Button btn_2_3_3_2;
  18.  
  19. @Override
  20. protected void onCreate(Bundle savedInstanceState) {
  21. super.onCreate(savedInstanceState);
  22. setContentView(R.layout.code_2_3_3);
  23. iv_scale = (ImageView) findViewById(R.id.iv_scale);
  24. findViewById(R.id.btn_center).setOnClickListener(this);
  25. findViewById(R.id.btn_fitCenter).setOnClickListener(this);
  26. findViewById(R.id.btn_centerCrop).setOnClickListener(this);
  27. findViewById(R.id.btn_centerInside).setOnClickListener(this);
  28. findViewById(R.id.btn_fitXY).setOnClickListener(this);
  29. findViewById(R.id.btn_fitStart).setOnClickListener(this);
  30. findViewById(R.id.btn_fitEnd).setOnClickListener(this);
  31. btn_2_3_3_2 = (Button) findViewById(R.id.btn_2_3_3_2);
  32. btn_2_3_3_2.setOnClickListener(this);
  33. }
  34.  
  35. @Override
  36. public void onClick(View v) {
  37. if (v.getId() == R.id.btn_center) {
  38. iv_scale.setScaleType(ImageView.ScaleType.CENTER);
  39. } else if (v.getId() == R.id.btn_fitCenter) {
  40. iv_scale.setScaleType(ImageView.ScaleType.FIT_CENTER);
  41. } else if (v.getId() == R.id.btn_centerCrop) {
  42. iv_scale.setScaleType(ImageView.ScaleType.CENTER_CROP);
  43. } else if (v.getId() == R.id.btn_centerInside) {
  44. iv_scale.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
  45. } else if (v.getId() == R.id.btn_fitXY) {
  46. iv_scale.setScaleType(ImageView.ScaleType.FIT_XY);
  47. } else if (v.getId() == R.id.btn_fitStart) {
  48. iv_scale.setScaleType(ImageView.ScaleType.FIT_START);
  49. } else if (v.getId() == R.id.btn_fitEnd) {
  50. iv_scale.setScaleType(ImageView.ScaleType.FIT_END);
  51. } else if (v.getId() == R.id.btn_2_3_3_2){
  52. class__2_3_3_2.startHome(class__2_3_3.this);
  53. }
  54. }
  55.  
  56. public static void startHome(Context mContext) {
  57. Intent intent = new Intent(mContext, class__2_3_3.class);
  58. mContext.startActivity(intent);
  59. }
  60.  
  61. }

Android 开发笔记___图像视图的更多相关文章

  1. Android 开发笔记___图像视图__简单截屏

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  2. Android 开发笔记___滚动视图__scroll view

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  3. Android 开发笔记___图像按钮__imageButton

    IMAGEBUTTON 其实派生自image view,而不是派生自button.,image view拥有的属性和方法,image button 统统拥有,只是imagebutton有个默认的按钮外 ...

  4. Android学习笔记-ImageView(图像视图)

    本节引言: 本节介绍的UI基础控件是:ImageView(图像视图),见名知意,就是用来显示图像的一个View或者说控件! 官方API:ImageView;本节讲解的内容如下: ImageView的s ...

  5. Android 开发笔记___初级控件之实战__计算器

    功能简单,实现并不难,对于初学者可以总和了解初级控件的基本使用. 用到的知识点如下: 线性布局 LinearLayout:整体界面是从上往下的,因此需要垂直方向的linearlayout:下面每行四个 ...

  6. Android 开发笔记___基本适配器的使用__BaseAdapter

    之前用到过ArryAdapter适用于纯文本的列表数据,SimpleAdapter适用于带图标的列表数据,但在实际应用中常常有更复杂的列表,比如同一项中存在多个控件,这时候用前面的两个会比较复杂,而且 ...

  7. Android 开发笔记___时间选择器---timePicker

    像datepicker一样,也有timepicker. 同样有timepickerdialog 所用到的方法还是一样,监听时间选择器的变化. package com.example.alimjan.h ...

  8. Android 开发笔记___实战项目:购物车

    购物车的应用很广泛,电商app基本上都有它的身影.由于它用到了多种存储方式,通过项目对数据的存储有更高层次的了解. 1.设计思路 首先看看购物车的外观.第一次进入时里面是空的,去购物页面加入购物车以后 ...

  9. Android 开发笔记___存储方式__共享参数__sharedprefences

    Android 的数据存储方式有四种,这次是[共享参数__sharedprefences] 听起来挺别扭的,平时看到的app里面,当用户删除了一些软件以后下次安装,发现原来的设置还在,这种情况就是把一 ...

随机推荐

  1. mongoDB学习手记1--Windows系统下的安装与启动

    第一步:下载安装包 我们首先需要下载 mongodb 的安装包,直接到官网下载即可.地址为:https://www.mongodb.com/download-center#community. 看下自 ...

  2. 不可不知的socket和TCP连接过程

    html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...

  3. 用 Python 撸一个区块链

    本文翻译自 Daniel van Flymen 的文章 Learn Blockchains by Building One 略有删改.原文地址:https://hackernoon.com/learn ...

  4. HIT 1917 Peaceful Commission

    这道题题意就是给你n对人,一对中编号为x,x+1,给你m对矛盾,表示这两个人不能同时选. 然后就是Two-Sat的模板题了,就是根据对称性,连边,加缩点,最后拓扑排序,求出一组可行解就可以了. #in ...

  5. JavaScript高级(01)

    前端开发工具 1.1. WebStorm介绍和下载 l  介绍 WebStorm是JetBrains 推出的一款强大的HTML5编辑工具,拥有丰富的代码快速编辑,可以智能的补全代码.代码格式化.htm ...

  6. Fiddler屏蔽某些url的抓取方法

    在用Fiddler调试网页的时候,可能某些频繁的ajax轮询请求会干扰我们,可以通过以下方法屏蔽某些url的抓取. 在需要屏蔽的url行上右键---->“Filter Now”-----> ...

  7. YYHS-Super Big Stupid Cross(二分+扫描线+平衡树)

    题目描述 “我是超级大沙茶”——Mato_No1 为了证明自己是一个超级大沙茶,Mato 神犇决定展示自己对叉(十字型)有多么的了 解. Mato 神犇有一个平面直角坐标系,上面有一些线段,保证这些线 ...

  8. JavaScript 版数据结构与算法(三)链表

    今天,我们要讲的是数据结构与算法中的链表. 链表简介 链表是什么?链表是一种动态的数据结构,这意味着我们可以任意增删元素,它会按需扩容.为何要使用链表?下面列举一些链表的用途: 因为数组的存储有缺陷: ...

  9. Python tkinter调整元件在窗口中的位置与几何布局管理

    Tkinter中的GUI总是有一个root窗口,不管你是主动或者别动获得.主窗口就是你的程序开始运行的时候创建的,在主窗口中你通常是放置了你主要的部件.另外,Tkinter脚本可以依据需要创建很多独立 ...

  10. ZOJ 2002 Copying Books 二分 贪心

    传送门:Zoj2002 题目大意:从左到右把一排数字k分,得到最小化最大份,如果有多组解,左边的尽量小. 思路:贪心+二分(参考青蛙过河). 方向:从右向左. 注意:有可能最小化时不够k分.如     ...