最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2015年12月08日 10:59:01   作者:Z2  
這篇文章主要介紹了新浪微博第三方登錄界面上下拉伸圖片之第三方開源PullToZoomListViewEx(二) 的相關(guān)資料,需要的朋友可以參考下

上篇文章給大家介紹了新浪微博第三方登錄界面上下拉伸圖片之第三方開源PullToZoomListViewEx(一),需要了解的朋友可以點擊了解詳情。

這是PullZoomView在ScrollView實現(xiàn),Android PullZoomView在ScrollView的實現(xiàn)是:PullToZoomScrollViewEx

下載地址:https://github.com/Frank-Zhu/PullZoomView

本文要說的PullToZoomScrollViewEx則以另外一種方式在Java代碼中動態(tài)的為PullZoomView裝載View:

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);
 } 

兩點內(nèi)容需要注意:

(1)所有Android PullZoomView的頭部及縮放效果都可以關(guān)閉或者開啟,具體方式就是通過改變設(shè)置各種方法的true或false值。以下是比較重要的幾個方法:

setParallax(boolean b);

true則有視差效果,false則無。

setHideHeader(boolean b);

true則隱藏自己定義的head view,false則顯示。

setZoomEnabled(boolean b);
true支持縮放,false不支持縮放。

默認(rèn)的,

setParallax(true);
setHideHeader(false);
setZoomEnabled(true);

(2)PullZoomView中嵌套的子View,需要通過getPullRootView().findViewById(R.id.xxxx)這樣的方式找出來,而不是直接的findViewById()。

下面給出一個完整例子加以說明。

先寫一個布局:

 <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> 

Java代碼:

 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);
  }
  // 設(shè)置頭部的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);
  }
 } 

 java代碼需要的子布局:

head_view.xml:

 <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> 

head_zoom_view.xml:

 <?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其實就放了一張可供縮放拉伸的圖片。

content_view.xml:

 <?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> 

實際開發(fā)中,如果確定要用ScrollView包括自己項目中的子View,那么content_view.xml就是其他View的裝載“父”布局。重點需要在content_view.xml中展開。

相關(guān)文章

  • Android使用GridView實現(xiàn)日歷功能示例(詳細(xì)代碼)

    Android使用GridView實現(xiàn)日歷功能示例(詳細(xì)代碼)

    本篇文章主要介紹了Android使用GridView實現(xiàn)日歷功能示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考,一起跟隨小編過來看看吧
    2017-01-01
  • API處理Android安全距離詳情

    API處理Android安全距離詳情

    這篇文章主要介紹了API處理Android安全距離詳情,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的朋友可以參考一下
    2022-06-06
  • Flutter進(jìn)階之實現(xiàn)動畫效果(四)

    Flutter進(jìn)階之實現(xiàn)動畫效果(四)

    這篇文章主要為大家詳細(xì)介紹了Flutter進(jìn)階之實現(xiàn)動畫效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-08-08
  • Android實現(xiàn)九宮格橫向左右滑動

    Android實現(xiàn)九宮格橫向左右滑動

    這篇文章主要為大家詳細(xì)介紹了Android實現(xiàn)九宮格橫向左右滑動,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-08-08
  • Android開發(fā)之滑動數(shù)值選擇器NumberPicker用法示例

    Android開發(fā)之滑動數(shù)值選擇器NumberPicker用法示例

    這篇文章主要介紹了Android開發(fā)之滑動數(shù)值選擇器NumberPicker用法,結(jié)合實例形式分析了Android滑動數(shù)值選擇器NumberPicker的功能、相關(guān)函數(shù)、事件監(jiān)聽、界面布局等操作技巧,需要的朋友可以參考下
    2019-03-03
  • Kotlin圖文并茂講解續(xù)體與續(xù)體攔截器和調(diào)度器

    Kotlin圖文并茂講解續(xù)體與續(xù)體攔截器和調(diào)度器

    這篇文章主要介紹了Kotlin開發(fā)中續(xù)體與續(xù)體攔截器和調(diào)度器的相關(guān)使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-08-08
  • Android?Studio實現(xiàn)簡單補間動畫

    Android?Studio實現(xiàn)簡單補間動畫

    這篇文章主要為大家詳細(xì)介紹了Android?Studio實現(xiàn)簡單補間動畫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • Kotlin學(xué)習(xí)教程之操作符重載詳解

    Kotlin學(xué)習(xí)教程之操作符重載詳解

    這篇文章主要給大家介紹了關(guān)于Kotlin學(xué)習(xí)教程之操作符重載的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-02-02
  • Android中Retrofit庫的高級使用與原理

    Android中Retrofit庫的高級使用與原理

    在 Android 開發(fā)中,網(wǎng)絡(luò)請求是一個極為關(guān)鍵的部分,Retrofit 作為一個強大的網(wǎng)絡(luò)請求庫,能夠簡化開發(fā)流程,提供高效的網(wǎng)絡(luò)請求能力,本文將深入介紹 Retrofit 的高級使用與原理,幫助讀者更全面地理解和應(yīng)用這一庫,需要的朋友可以參考下
    2023-08-08
  • Android自定義控件實現(xiàn)底部菜單(下)

    Android自定義控件實現(xiàn)底部菜單(下)

    這篇文章主要為大家詳細(xì)介紹了Android自定義控件實現(xiàn)底部菜單的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-01-01

最新評論

安新县| 合作市| 涞水县| 龙胜| 红安县| 德保县| 怀集县| 黄陵县| 永仁县| 洪雅县| 韩城市| 隆安县| 阿拉善左旗| 扎囊县| 浑源县| 汝阳县| 新邵县| 蒲江县| 湖口县| 东莞市| 广平县| 宣城市| 和林格尔县| 金沙县| 长阳| 久治县| 梁山县| 靖江市| 新郑市| 新绛县| 汶川县| 塔河县| 陆川县| 含山县| 闻喜县| 海淀区| 曲周县| 手机| 和顺县| 墨江| 高密市|