<?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"> <ImageView
android:id="@+id/iv_scale"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginTop="10dp"
android:src="@drawable/apple1" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android: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
android: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:layout_height="wrap_content"
android:layout_weight="1"
android:text="centerInside"
android:textColor="#000000"
android:textSize="11sp" /> </LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android: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" /> <Button
android:id="@+id/btn_fitStart"
android:layout_width="0dp"
android:layout_height="wrap_content"
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> <Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="截屏"
android:id="@+id/btn_2.3.3.2"/> </LinearLayout>

  Java

package com.example.alimjan.hello_world;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView; /**
* Created by alimjan on 6/30/2017.
*/ public class class__2_3_3 extends AppCompatActivity implements View.OnClickListener {
private ImageView iv_scale;
private Button btn_2_3_3_2; @Override
protected void onCreate(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 void onClick(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 void startHome(Context mContext) {
Intent intent = new Intent(mContext, class__2_3_3.class);
mContext.startActivity(intent);
} }

最新文章

  1. 如何理解typedef void (*pfun)(void)
  2. cookie、session与token
  3. 记一次故障处理----主机异常关闭后mongodb二进制文件损坏
  4. NSTimer scheduledTimerWithTimeInterval与timerWithTimeInterval、initWithFireDate的区别
  5. Netlog 的数据库及 LAMP 架构
  6. 谷歌浏览器 DEV Tools
  7. insert 另外一种用法
  8. JAVA混型和潜在类型机制
  9. 漂亮的代码3:flatten 一个数组
  10. Ubuntu与Centos在登陆安全方面的比较
  11. maven入门 (二)_私服安装与上传下载
  12. Solr 13 - 在URL地址栏中操作Solr集群 - 包括CRUD、别名、切割分片、更新配置
  13. 数据库查询的数据导出到xls表,集合数据导出到xls表
  14. Docker Compose 介绍安装
  15. Windows7 VS2015 下编译 Python3.6.6
  16. Springboot 2.0 - 集成redis
  17. 带搜索框的jQuery下拉框插件
  18. html和vue框架
  19. js中编写velocity逻辑
  20. Reddit CEO亲自诠释内容审核的无奈

热门文章

  1. 【JavaScript】设计模式-module模式及其改进
  2. DOM中元素对象的属性方法
  3. AF_INET
  4. 【转】css清除浮动float的三种方法总结,为什么清浮动?浮动会有那些影响?
  5. Eclipse自动补全增强
  6. Maven-环境搭建以及建立Maven项目
  7. Java—Day5课堂练习
  8. 简单说下C#变量的作用域
  9. Babel运行原理
  10. 创建UWP通用应用程序