强大的图片浏览器---------增强、降低透明度、切换下一张
xml-------布局-----------------------------------
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/plus" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="增大透明度" /> <Button android:id="@+id/minus" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="降低透明度" /> <Button android:id="@+id/next" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="下一张" /> </LinearLayout> <ImageView android:id="@+id/image1" android:layout_width="wrap_content" android:layout_height="280dp" android:src="@drawable/img3" android:scaleType="fitCenter"/><ImageView android:id="@+id/image2" android:layout_width="120dp" android:layout_height="120dp" android:background="#00f" android:layout_margin="10dp"/></LinearLayout> MainActivity.java-----------------Java调用----------------------------------
int[] images=new int[]{ R.drawable.img1, R.drawable.img2, R.drawable.img3, R.drawable.img4, R.drawable.img5, }; int currentIMG=2; private int alpha=255; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.imageviewer); final Button plus=(Button) findViewById(R.id.plus); final Button minus=(Button) findViewById(R.id.minus); final ImageView image1=(ImageView) findViewById(R.id.image1); final ImageView image2=(ImageView) findViewById(R.id.image2); final Button next=(Button) findViewById(R.id.next); next.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { image1.setImageResource(images[++currentIMG%images.length]); } }); View.OnClickListener listener=new View.OnClickListener(){ @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public void onClick(View v){ if(v==plus){ alpha+=20; } if(v==minus){ alpha-=20; } if(alpha>=255){ alpha=255; } if(alpha<=0){ alpha=0; } image1.setImageAlpha(alpha); } }; plus.setOnClickListener(listener); minus.setOnClickListener(listener);image1.setOnTouchListener(new View.OnTouchListener() { @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public boolean onTouch(View v, MotionEvent event) { BitmapDrawable bitmapDrawable=(BitmapDrawable) image1.getDrawable(); Bitmap bitmap=bitmapDrawable.getBitmap(); double scale=1.0*bitmap.getHeight()/image1.getHeight(); int x=(int) (event.getX()*scale); int y=(int) (event.getY()*scale); if(x+120>bitmap.getWidth()){ x=bitmap.getWidth()-120; } if(y+120>bitmap.getHeight()){ y=bitmap.getHeight()-120; } image2.setImageBitmap(Bitmap.createBitmap(bitmap,x,y,120,120)); image2.setImageAlpha(alpha); return false; }}); }
转载于:https://www.cnblogs.com/ZeroMurder/p/5929938.html
强大的图片浏览器---------增强、降低透明度、切换下一张相关推荐
- 用C#把一个文件夹中的图片全部读取出来,然后点击下一张,能依次循环显示。
1.新建一个Form工程. 2.在Form1上添加一个PictureBox控件. 3.添加三个私有变量: private int ImageCount; //图片总数 private List< ...
- 仿快图系统自带图片浏览器应用源码项目
仿快图系统自带图片浏览器应用源码,最近在做一个微博i动态模块,需要查看他人相册照片或者微博内容图片等.看到QQ空间那个效果不错,尝试了不少方法来实现,均不是怎么理想.最初是想通过自定义GroupVie ...
- java课程设计图片浏览器_java课程设计图片浏览器
[实例简介] 图片浏览器最基本的功能是能浏览一个目录中的所有图片,并可以点击浏览上一张图片或者下一张图片,还有对图片放大与缩小,或者翻转图片等操作,在这里,实现了图片的浏览功能,导航功能(下一张.上一 ...
- 23.Qt Quick QML-400行实现一个好看的图片浏览器-支持多个图片浏览、缩放、旋转、滑轮切换图片...
之前我们已经学习了Image.Layout布局.MouseArea.Button.GroupBox.FileDialog等控件. 所以本章综合之前的每章的知识点,来做一个图片浏览器,笔者使用的Qt版本 ...
- ImageView组件的应用:图片浏览器
随时随地技术实战干货,获取项目源码.学习资料,请关注源代码社区公众号(ydmsq666) 本实例用来练习ImageView组件的使用,实现一个图片浏览器,该图片浏览器可以改变所查看的图片的透明度,切换 ...
- XnViewMP图片浏览器
今天小编给大家带来的是XnViewMP图片浏览器,这是一款非常棒的完全免费图片浏览器,同时支持多种语言,并且是纯绿色免安装,即下即用.软件支持100多种图片格式,还具有浏览器.幻灯片.屏幕捕捉.缩略图 ...
- android开发 图片浏览器,Android开发之图片浏览器
Android图片浏览器,可以调整图片透明度和按顺序切换图片. 以下是activity的xml文件: xmlns:tools="http://schemas.android.com/tool ...
- 【Android 应用开发】AndroidUI设计 之 图片浏览器
图片浏览器效果图 : 源码下载地址 : -- CSDN : http://download.csdn.net/detail/han1202012/6875083 -- GitHub : https:/ ...
- 【好工具】安利一款优秀的图片浏览器
欢迎大家来到<好工具>专栏,这个专栏面向所有希望获得高效生产力工具的朋友.在这个专栏里,我们会和大家聊聊那些狂拽酷霸炫的生产力工具! 相信大家一定和我一样,茫然于庞大的工具海洋,却仍找不到 ...
最新文章
- OpenGL学习(hello)
- Python每日一练0018
- CSS中clear属性的both、left和right浅析
- CO葵花宝典-4.物料成本估算配置
- ubuntu虚拟机卡住开机_虚拟机Ubuntu开机问题及解决方法
- ant target间的dependency
- myeclipse安装 配置Maven3
- win2003 IIS6配置PHP 5.3.3(fastCGI方式+eAccelerator)+ASP.NET 4.0(MVC3)
- 想创业?从学会需求谈判开始
- Unity3D学习笔记(二十七):MVC框架下的背包系统(2)
- linux scp 使用简单说明
- IDEA 配置SVN ,SVN安装后没有svn.exe
- 杀猪、打狗、护牛、赛马、放虎——几种管理方法
- iframe框架下的子父级页面监控页面关闭事件
- Trunk技术需求与应用
- EXCEL 启动参数设置
- 九宫图-图片轮播-兼容IE8和Chrome浏览器
- 【愚公系列】2022年10月 微信小程序-电商项目-确认订单功能实现
- 整理全菜30篇学习vue和脚手架的笔记
- 【转】几毛钱的32768晶振,这也能写出一篇干货?
热门文章
- 微信小程序数据拼接_微信小程序使用原生WebSokcet实现断线重连及数据拼接
- angular4更改表单中显示的值_关于angular4中FormBuilder重新赋值时发生的问题
- 文件夹内的文本行数_重温生物信息重要的文本处理命令(实例命令及解释)
- php phpredis,PHP_PHP中redis的用法深入解析,redis是一个key-value存储系统。 - phpStudy...
- 信息服务器 iis 5.0,使用IIS 5.0调整Web服务器的艺术与科学(4)
- 使用方法_防爆配电箱使用方法及使用条件
- mysql数据库的函数_详解数据库_MySQL: mysql函数
- 使用SpringBoot+JPA报错Incorrect syntax near 'hibernate_sequence'
- oracle12图书馆,Oracle图书馆管理系统
- python图像识别数字_使用python和tensorflow从Image中识别数字