[Android]ScrollView和ListView上方的headView的下拉放大效果-PullZoomView的使用篇

欢迎光临程序猿零食铺:https://shop66096489.taobao.com
感谢:
https://github.com/Frank-Zhu/PullZoomView

  先看效果,来自github上的项目PullZoomView:
  地址:https://github.com/Frank-Zhu/PullZoomView
  本篇文章主要针对PullZoomView中的Zoom Scroll View为例子说明如何使用该库,其实使用很简单,就是导入android studio运行的时候碰到了一些坎。
  2015年七月底clone到自己android studio的时候,遇到来一个奇葩的问题,不过已经解决,解决方案可点击链接 [Android Debug]aapt.exe” finished with non-zero exit value 1
  已经放一份稍微修改过的代码到csdn,下载地址:
http://download.csdn.net/detail/zhouhuakang/8955079

  
1.PullZoomView的PullToZoomScrollActivity中将一个页面分为三个部分,分别是头部、头部下面用来放大的图片、头部下方显示的内容,利用定制过的PullToZoomScrollViewEx.setxxx方法载入三个部分。

PullToZoomScrollActivity的方法

private void loadViewForCode() {
        //载入视图
        PullToZoomScrollViewEx scrollView =(PullToZoomScrollViewEx) findViewById(R.id.scroll_view);
        View headView = LayoutInflater.from(this).inflate(R.layout.profile_head_view, null, false);
        View zoomView = LayoutInflater.from(this).inflate(R.layout.profile_zoom_view, null, false);
        View contentView = LayoutInflater.from(this).inflate(R.layout.profile_content_view, null, false);
        //加入到ScrollView中
        scrollView.setHeaderView(headView);
        scrollView.setZoomView(zoomView);
        scrollView.setScrollContentView(contentView);
    }

2.之后在onCreate中设置头部的高度即可

DisplayMetrics localDisplayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
        int mScreenHeight = localDisplayMetrics.heightPixels;
        int mScreenWidth = localDisplayMetrics.widthPixels;
        LinearLayout.LayoutParams localObject = new LinearLayout.LayoutParams(mScreenWidth, (int) (9.0F * (mScreenHeight / 16.0F)));
        scrollView.setHeaderLayoutParams(localObject);
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值