国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - Android - 新浪微博第三方登錄界面上下拉伸圖片之第三方開源PullToZoomListViewEx(二)

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

2021-04-19 15:25Z2 Android

這篇文章主要介紹了新浪微博第三方登錄界面上下拉伸圖片之第三方開源PullToZoomListViewEx(二) 的相關資料,需要的朋友可以參考下

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

這是PullZoomView在ScrollView實現,Android PullZoomView在ScrollView的實現是:PullToZoomScrollViewEx

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

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

?
1
2
3
4
5
6
7
8
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);
 }

兩點內容需要注意:

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

setParallax(boolean b);

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

setHideHeader(boolean b);

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

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

默認的,

?
1
2
3
setParallax(true);
setHideHeader(false);
setZoomEnabled(true);

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

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

先寫一個布局:

?
1
2
3
4
5
6
7
8
9
10
<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代碼:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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);
 }
}

 

 java代碼需要的子布局:

head_view.xml:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<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:

?
1
2
3
4
5
6
7
8
<?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:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?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>

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

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 亚洲精品一区二区三区在线观看 | 国产精品日韩一区二区 | 中文字幕精品视频 | 欧美综合在线一区 | 成人精品福利 | www,99热| 久久精品国产亚洲 | 国内精品一区二区三区 | 久久久一区二区三区 | 99视频在线免费观看 | 免费看黄色一级视频 | 欧美三区 | 婷婷久久一区 | 日韩精品区 | 午夜爱爱毛片xxxx视频免费看 | 久久九九国产精品 | 欧美日韩在线播放 | 亚洲免费视频在线观看 | 一级片在线播放 | 久久妇女高潮片免费观看 | 黄色成人在线 | 在线国产小视频 | 一区二区精品在线 | 欧美精品在线免费观看 | 亚洲日韩中文字幕一区 | 欧美成人免费在线 | 日韩色影 | 久久精品超碰 | 欧美二三区 | 国产目拍亚洲精品99久久精品 | 奇米在线 | 日韩一区二区三区在线视频 | 日本免费在线视频 | 精品九九久久 | 国产高清一区二区 | 亚洲一区久久 | 美女视频一区二区三区 | 青青草久久网 | 久久99精品国产麻豆婷婷洗澡 | 精品欧美乱码久久久久久1区2区 | 视频一区二区三区中文字幕 |