2011.10.14(2)——— android 仿照微信的图片展示功能 之 放大超过屏幕
16lz
2021-12-04
2011.10.14(2)——— android 仿照微信的图片展示功能 之 放大超过屏幕
1、
我想是不是因为宽高设置的为fill_parent 所以造成了图片只能显示到屏幕大小呢
修改
运行之后 还是不行 依然只能在屏幕内显示
2、突然想起来 前两天做了一个只显示图片中间位置的例子
这个还是设计到 android:scaleType
因为系统默认是用fitCenter显示的
也就是按比例拉伸图片,拉伸后图片的高度为View的高度,且显示在View的中间
按比例所以 原图是宽大于高 修改的图也将会是宽大于高的
所以我们可以改为center
哈哈 果然可以 效果如下:
还有一个小功能 就是单击图片的话 隐藏下方的工具条
修改
改成wrap_content
增加touch监听
注册即可
1、
<ImageView android:id="@+id/myImageView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="center"/>
我想是不是因为宽高设置的为fill_parent 所以造成了图片只能显示到屏幕大小呢
修改
android:layout_width="wrap_content"android:layout_height="wrap_content"
运行之后 还是不行 依然只能在屏幕内显示
2、突然想起来 前两天做了一个只显示图片中间位置的例子
http://lipeng88213.iteye.com/admin/blogs/1180817
这个还是设计到 android:scaleType
因为系统默认是用fitCenter显示的
也就是按比例拉伸图片,拉伸后图片的高度为View的高度,且显示在View的中间
按比例所以 原图是宽大于高 修改的图也将会是宽大于高的
所以我们可以改为center
<ImageView android:id="@+id/myImageView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="center"/>
哈哈 果然可以 效果如下:
还有一个小功能 就是单击图片的话 隐藏下方的工具条
修改
<ImageView android:id="@+id/myImageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="center"/>
改成wrap_content
增加touch监听
@Overridepublic boolean onTouch(View v, MotionEvent event) {// TODO Auto-generated method stubLog.i(TAG, "onTouch...");if(isVisible){zoomControll.setVisibility(View.INVISIBLE);isVisible = false;}else{zoomControll.setVisibility(View.VISIBLE);isVisible = true;}return super.onTouchEvent(event); }
注册即可
mImageView.setOnTouchListener(this);
更多相关文章
- 快速进入Android世界
- android:layout_weight总有你不知道的用法.
- Android软键盘的显示与隐藏
- Android屏幕密度(Density)和分辨率的关系
- android selector
- android TextView属性大全
- Android屏幕适配攻略
- Android如何使布局中图(ImageButton)和文字(TextView)同时获得press
- Android(安卓)游戏开发的一些基础和经验