android 按下缩小效果松开恢复_Android 按压缩放效果&FastBlur毛玻璃效果

一、按压缩放效果

ImageView实现按压后实现动画缩小,松手或者滑出ImageView的边界时,实现动画放大效果。

具体案例请参考去哪儿网的 【去哪儿旅行app】

首先是布局文件image_wall_layout.xml

android:layout_width="match_parent"

android:layout_height="match_parent"

android:gravity="center"

android:orientation="horizontal"

android:padding="10dip"

android:weightSum="2" >

android:id="@+id/layout_wallitem_1"

android:layout_width="match_parent"

android:layout_height="80dip"

android:layout_marginBottom="16dip"

android:layout_weight="1"

android:scaleType="fitCenter"

android:src="@drawable/ic_category_15" />

android:layout_width="16dip"

android:layout_height="match_parent" />

android:id="@+id/layout_wallitem_2"

android:layout_width="match_parent"

android:layout_height="80dip"

android:layout_marginBottom="16dip"

android:layout_weight="1"

android:scaleType="fitCenter"

android:src="@drawable/ic_category_2" />

Activity代码

public class ImageWallActivity extends Activity implements OnTouchListener {

private View leftLayoutItem;

private View rightLayoutItem;

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.image_wall_layout);

leftLayoutItem =  findViewById(R.id.layout_wallitem_1);

rightLayoutItem =  findViewById(R.id.layout_wallitem_2);

leftLayoutItem.setOnTouchListener(this);

rightLayoutItem.setOnTouchListener(this);

}

@Override

protected void onDestroy() {

super.onDestroy();

}

@Override

public boolean onTouch(View v, MotionEvent event) {

switch (event.getAction())

{

case MotionEvent.ACTION_DOWN:

scaleToSmaller(v);

break;

case MotionEvent.ACTION_CANCEL:

case MotionEvent.ACTION_UP:

scaleToNo

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值