欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

新浪微博第三方登錄界面上下拉伸圖片之第三方開源PullToZoomListViewEx(一)

 更新時(shí)間:2015年12月08日 10:50:03   作者:Z2  
PullZoomView要實(shí)現(xiàn)兩類,一類是典型的Android ListView,另外一類是Android 的scroll view。本文先介紹PullZoomView在ListView上的實(shí)現(xiàn):PullToZoomListViewEx

Android PullZoomView是github上面的一個(gè)第三方開源項(xiàng)目,該項(xiàng)目實(shí)現(xiàn)的功能被新浪微博的移動(dòng)端廣泛使用,其效果就是,當(dāng)用戶在下拉過程中,頭部的圖片會(huì)有一定的拉伸,當(dāng)用戶松開時(shí)候,圖片又收縮復(fù)位,下載地址:https://github.com/Frank-Zhu/PullZoomView

PullZoomView要實(shí)現(xiàn)兩類,一類是典型的Android ListView,另外一類是Android 的scroll view。本文先介紹PullZoomView在ListView上的實(shí)現(xiàn):PullToZoomListViewEx。

首先需要把PullToZoomListViewEx像ListView一樣寫進(jìn)布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.zzw.testpullzoomview.MainActivity" >
<com.ecloud.pulltozoomview.PullToZoomListViewEx
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
custom:headerView="@layout/head_view"
custom:zoomView="@layout/head_zoom_view" />
</RelativeLayout>

需要注意的是,需要定義一個(gè)headerView:

custom:headerView="@layout/head_view"
<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:background="@android:color/holo_red_light"
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="注冊(cè)"
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> 

此處的headerView是位于PullToZoomListViewEx頭部的一個(gè)子布局,里面定義一些控件將出現(xiàn)在PullToZoomListViewEx的頭部,但此處的headerView并不會(huì)縮放,只是可以看到此處的headerView在隨著下拉過程中移位。

而定義的custom:zoomView:

custom:zoomView="@layout/head_zoom_view"
<?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" /> 

head_zoom_view其實(shí)就是簡(jiǎn)單的放一張圖片。

則是真正的要縮放伸展的View,此處通常會(huì)放置一張圖片,在用戶下拉過程中滑動(dòng)縮放,產(chǎn)生奇妙的視覺效果。
在一定程度上講,zoomView是襯托在headerView底下的。headerView是一個(gè)正常顯示的Android View布局,而zoomView則是可以產(chǎn)生動(dòng)態(tài)縮放和收縮效果的特殊zoom View。
寫一個(gè)完整的例子加以說明。

Java代碼:

package com.zzw.testpullzoomview;
import com.ecloud.pulltozoomview.PullToZoomListViewEx;
import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PullToZoomListViewEx listView = (PullToZoomListViewEx) findViewById(R.id.listView);
String data[] = new String[];
for (int i = ; i < data.length; i++) {
data[i] = "測(cè)試數(shù)據(jù)" + i;
}
listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_, data));
listView.getPullRootView().setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.d("position", "getPullRootView--->position = " + position);
}
});
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.d("position", "position = " + position);
}
});
setPullToZoomListViewExHeaderLayoutParams(listView);
}
// 設(shè)置頭部的View的寬高。
private void setPullToZoomListViewExHeaderLayoutParams(PullToZoomListViewEx listView) {
DisplayMetrics localDisplayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
int mScreenHeight = localDisplayMetrics.heightPixels;
int mScreenWidth = localDisplayMetrics.widthPixels;
AbsListView.LayoutParams localObject = new AbsListView.LayoutParams(mScreenWidth,
(int) (.f * (mScreenWidth / .F)));
listView.setHeaderLayoutParams(localObject);
}
}

以上所述是本文關(guān)于新浪微博第三方登錄界面上下拉伸圖片之第三方開源PullToZoomListViewEx(一)的全部敘述,希望大家喜歡,下篇給大家介紹新浪微博第三方登錄界面上下拉伸圖片之第三方開源PullToZoomListViewEx(二),希望大家繼續(xù)關(guān)注。

相關(guān)文章

  • Android使用GridView實(shí)現(xiàn)橫向滾動(dòng)效果

    Android使用GridView實(shí)現(xiàn)橫向滾動(dòng)效果

    這篇文章主要為大家詳細(xì)介紹了Android使用GridView實(shí)現(xiàn)橫向滾動(dòng)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-07-07
  • Android網(wǎng)絡(luò)狀態(tài)實(shí)時(shí)監(jiān)聽實(shí)例代碼(二)

    Android網(wǎng)絡(luò)狀態(tài)實(shí)時(shí)監(jiān)聽實(shí)例代碼(二)

    這篇文章主要介紹了Android網(wǎng)絡(luò)狀態(tài)實(shí)時(shí)監(jiān)聽實(shí)例代碼(2)的相關(guān)資料,需要的朋友可以參考下
    2016-03-03
  • Android結(jié)合kotlin使用coroutine的方法實(shí)例

    Android結(jié)合kotlin使用coroutine的方法實(shí)例

    這篇文章主要給大家介紹了關(guān)于Android結(jié)合kotlin使用coroutine的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • Android 中ListView setOnItemClickListener點(diǎn)擊無效原因分析

    Android 中ListView setOnItemClickListener點(diǎn)擊無效原因分析

    這篇文章主要介紹了Android 中ListView setOnItemClickListener點(diǎn)擊無效原因分析的相關(guān)資料,需要的朋友可以參考下
    2016-01-01
  • Android Broadcast原理分析之registerReceiver詳解

    Android Broadcast原理分析之registerReceiver詳解

    這篇文章主要介紹了Android Broadcast原理分析之registerReceiver詳解,本篇文章通過簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-08-08
  • android studio 3.6 中配置svn的教程

    android studio 3.6 中配置svn的教程

    這篇文章主要介紹了android studio 3.6 配置svn的教程,本文所用的as版本是3.6.1,通過圖文實(shí)例相結(jié)合給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-03-03
  • Android語音識(shí)別技術(shù)詳解及實(shí)例代碼

    Android語音識(shí)別技術(shù)詳解及實(shí)例代碼

    這篇文章主要介紹了Android語音識(shí)別技術(shù)的相關(guān)資料,并附實(shí)例代碼及實(shí)例實(shí)現(xiàn)效果圖,需要的朋友可以參考下
    2016-09-09
  • Android Retrofit2數(shù)據(jù)解析代碼解析

    Android Retrofit2數(shù)據(jù)解析代碼解析

    這篇文章主要介紹了Android Retrofit2數(shù)據(jù)解析代碼解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-12-12
  • Android App數(shù)據(jù)格式Json解析方法和常見問題

    Android App數(shù)據(jù)格式Json解析方法和常見問題

    JSON數(shù)據(jù)格式,在Android中被廣泛運(yùn)用于客戶端和網(wǎng)絡(luò)(或者說服務(wù)器)通信,非常有必要系統(tǒng)的了解學(xué)習(xí)。恰逢本人最近對(duì)json做了一個(gè)簡(jiǎn)單的學(xué)習(xí),特此總結(jié)一下,以饗各位
    2014-03-03
  • Android仿京東、天貓下拉刷新效果

    Android仿京東、天貓下拉刷新效果

    這篇文章主要為大家詳細(xì)介紹了Android仿京東、天貓下拉刷新效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-03-03

最新評(píng)論