private void loadViewForPullToZoomScrollView(PullToZoomScrollViewEx scrollView) {
View headView = LayoutInflater.from(this).inflate(R.layout.head_view, null);
View zoomView = LayoutInflater.from(this).inflate(R.layout.head_zoom_view, null);
View contentView = LayoutInflater.from(this).inflate(R.layout.content_view, null);
scrollView.setHeaderView(headView);
scrollView.setZoomView(zoomView);
scrollView.setScrollContentView(contentView);
}
setParallax(true); setHideHeader(false); setZoomEnabled(true);
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:custom="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" > <com.ecloud.pulltozoomview.PullToZoomScrollViewEx android:id="@+id/scroll_view" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout>
package com.zzw.testpullzoomview_scrollview;
import com.ecloud.pulltozoomview.PullToZoomScrollViewEx;
import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 注意初始化顺序,不要弄乱,否则抛出运行时空指针
PullToZoomScrollViewEx scrollView = (PullToZoomScrollViewEx) findViewById(R.id.scroll_view);
loadViewForPullToZoomScrollView(scrollView);
scrollView.getPullRootView().findViewById(R.id.tv_test).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("PullToZoomScrollViewEx", "onClick");
}
});
scrollView.getPullRootView().findViewById(R.id.tv_test).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e("PullToZoomScrollViewEx", "onClick");
}
});
scrollView.getPullRootView().findViewById(R.id.tv_test).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("PullToZoomScrollViewEx", "onClick");
}
});
setPullToZoomViewLayoutParams(scrollView);
}
private void loadViewForPullToZoomScrollView(PullToZoomScrollViewEx scrollView) {
View headView = LayoutInflater.from(this).inflate(R.layout.head_view, null);
View zoomView = LayoutInflater.from(this).inflate(R.layout.head_zoom_view, null);
View contentView = LayoutInflater.from(this).inflate(R.layout.content_view, null);
scrollView.setHeaderView(headView);
scrollView.setZoomView(zoomView);
scrollView.setScrollContentView(contentView);
}
// 设置头部的View的宽高。
private void setPullToZoomViewLayoutParams(PullToZoomScrollViewEx scrollView) {
DisplayMetrics localDisplayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
int mScreenHeight = localDisplayMetrics.heightPixels;
int mScreenWidth = localDisplayMetrics.widthPixels;
LinearLayout.LayoutParams localObject = new LinearLayout.LayoutParams(mScreenWidth,
(int) (.F * (mScreenWidth / .F)));
scrollView.setHeaderLayoutParams(localObject);
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:gravity="bottom">
<ImageView
android:id="@+id/iv_user_head"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/tv_user_name"
android:textSize="sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/iv_user_head"
android:layout_centerHorizontal="true"
android:text="新浪微博"
android:textColor="#ffffff" />
<LinearLayout
android:id="@+id/ll_action_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#"
android:layout_alignParentBottom="true"
android:padding="dip">
<TextView
android:id="@+id/tv_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="注册"
android:layout_weight=""
android:textSize="sp"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#ffffff" />
<TextView
android:id="@+id/tv_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="登录"
android:layout_weight=""
android:textSize="sp"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>
<?xml version="." encoding="utf-"?> <ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/imageView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_horizontal" android:scaleType="centerCrop" android:src="@drawable/a" />
<?xml version="." encoding="utf-"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffffff" android:orientation="vertical" > <TextView android:id="@+id/tv_test" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:padding="dp" android:text="test" android:textSize="sp" /> <TextView android:id="@+id/tv_test" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:padding="dp" android:text="test" android:textSize="sp" /> <TextView android:id="@+id/tv_test" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:padding="dp" android:text="test" android:textSize="sp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:padding="dp" android:text="test" android:textSize="sp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:padding="dp" android:text="test" android:textSize="sp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#eeeeee" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:padding="dp" android:text="test" android:textSize="sp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:padding="dp" android:text="test" android:textSize="sp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:padding="dp" android:text="test" android:textSize="sp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:padding="dp" android:text="test" android:textSize="sp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:padding="dp" android:text="test" android:textSize="sp" /> </LinearLayout>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有