Android 开发笔记___图像视图
- <?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);
- }
- }
Android 开发笔记___图像视图的更多相关文章
- Android 开发笔记___图像视图__简单截屏
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- Android 开发笔记___滚动视图__scroll view
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- Android 开发笔记___图像按钮__imageButton
IMAGEBUTTON 其实派生自image view,而不是派生自button.,image view拥有的属性和方法,image button 统统拥有,只是imagebutton有个默认的按钮外 ...
- Android学习笔记-ImageView(图像视图)
本节引言: 本节介绍的UI基础控件是:ImageView(图像视图),见名知意,就是用来显示图像的一个View或者说控件! 官方API:ImageView;本节讲解的内容如下: ImageView的s ...
- Android 开发笔记___初级控件之实战__计算器
功能简单,实现并不难,对于初学者可以总和了解初级控件的基本使用. 用到的知识点如下: 线性布局 LinearLayout:整体界面是从上往下的,因此需要垂直方向的linearlayout:下面每行四个 ...
- Android 开发笔记___基本适配器的使用__BaseAdapter
之前用到过ArryAdapter适用于纯文本的列表数据,SimpleAdapter适用于带图标的列表数据,但在实际应用中常常有更复杂的列表,比如同一项中存在多个控件,这时候用前面的两个会比较复杂,而且 ...
- Android 开发笔记___时间选择器---timePicker
像datepicker一样,也有timepicker. 同样有timepickerdialog 所用到的方法还是一样,监听时间选择器的变化. package com.example.alimjan.h ...
- Android 开发笔记___实战项目:购物车
购物车的应用很广泛,电商app基本上都有它的身影.由于它用到了多种存储方式,通过项目对数据的存储有更高层次的了解. 1.设计思路 首先看看购物车的外观.第一次进入时里面是空的,去购物页面加入购物车以后 ...
- Android 开发笔记___存储方式__共享参数__sharedprefences
Android 的数据存储方式有四种,这次是[共享参数__sharedprefences] 听起来挺别扭的,平时看到的app里面,当用户删除了一些软件以后下次安装,发现原来的设置还在,这种情况就是把一 ...
随机推荐
- mongoDB学习手记1--Windows系统下的安装与启动
第一步:下载安装包 我们首先需要下载 mongodb 的安装包,直接到官网下载即可.地址为:https://www.mongodb.com/download-center#community. 看下自 ...
- 不可不知的socket和TCP连接过程
html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...
- 用 Python 撸一个区块链
本文翻译自 Daniel van Flymen 的文章 Learn Blockchains by Building One 略有删改.原文地址:https://hackernoon.com/learn ...
- HIT 1917 Peaceful Commission
这道题题意就是给你n对人,一对中编号为x,x+1,给你m对矛盾,表示这两个人不能同时选. 然后就是Two-Sat的模板题了,就是根据对称性,连边,加缩点,最后拓扑排序,求出一组可行解就可以了. #in ...
- JavaScript高级(01)
前端开发工具 1.1. WebStorm介绍和下载 l 介绍 WebStorm是JetBrains 推出的一款强大的HTML5编辑工具,拥有丰富的代码快速编辑,可以智能的补全代码.代码格式化.htm ...
- Fiddler屏蔽某些url的抓取方法
在用Fiddler调试网页的时候,可能某些频繁的ajax轮询请求会干扰我们,可以通过以下方法屏蔽某些url的抓取. 在需要屏蔽的url行上右键---->“Filter Now”-----> ...
- YYHS-Super Big Stupid Cross(二分+扫描线+平衡树)
题目描述 “我是超级大沙茶”——Mato_No1 为了证明自己是一个超级大沙茶,Mato 神犇决定展示自己对叉(十字型)有多么的了 解. Mato 神犇有一个平面直角坐标系,上面有一些线段,保证这些线 ...
- JavaScript 版数据结构与算法(三)链表
今天,我们要讲的是数据结构与算法中的链表. 链表简介 链表是什么?链表是一种动态的数据结构,这意味着我们可以任意增删元素,它会按需扩容.为何要使用链表?下面列举一些链表的用途: 因为数组的存储有缺陷: ...
- Python tkinter调整元件在窗口中的位置与几何布局管理
Tkinter中的GUI总是有一个root窗口,不管你是主动或者别动获得.主窗口就是你的程序开始运行的时候创建的,在主窗口中你通常是放置了你主要的部件.另外,Tkinter脚本可以依据需要创建很多独立 ...
- ZOJ 2002 Copying Books 二分 贪心
传送门:Zoj2002 题目大意:从左到右把一排数字k分,得到最小化最大份,如果有多组解,左边的尽量小. 思路:贪心+二分(参考青蛙过河). 方向:从右向左. 注意:有可能最小化时不够k分.如 ...