Android開源:TransferImage - 仿微博、微信、qq 點擊縮略圖, 顯示高清圖 UI 組件

tpjc9094 7年前發布 | 12K 次閱讀 安卓開發 Android開發 移動開發

TransferImage

仿微博、微信、qq 點擊縮略圖后預覽高清圖的組件

TransferImage 是一款模仿微博、微信、qq的高清圖查看控件, 實現了在列表控件(ListView, RecycleView, GridView 等...)中 點擊縮略圖后播放過渡動畫, 加載高清圖, 加載高清圖時同時顯示加載進度條, 加載完成后顯示高清圖的一個組件。同時關閉 TransferImage 也會有對應的過渡動畫.

此庫若有不完善的地方, 請提 Issues, 我會盡快修復改善

支持或包含的功能:

  • 打開和關閉 TransferImage 的過渡動畫, 支持自定義
  • 圖片加載內置了一個使用 Glide 框架的圖片加載器, 支持自定義
  • 圖片支持手勢操作, 可縮放、雙擊、移動
  • 圖片加載時的進度條, 支持自定義
  • 圖片索引指示器, 支持自定義

Preview

預覽圖圖片質量有問題, 會出現卡頓的現象, 真實項目中不會出現.

Usage

transferLayout = new TransferImage.Builder(GroupImageActivity.this)
        .setBackgroundColor(Color.BLACK)
        .setMissPlaceHolder(R.mipmap.ic_launcher)
        .setOriginImageList(imageViewList)
        .setImageUrlList(imageStrList)
        .setOriginIndex(imageViewList.indexOf(v))
        .setOffscreenPageLimit(1)
        .create();
transferLayout.show();

注意:需要在 Activity 中重寫 onBackPressed 方法 (如果有 BaseActivity, 在 BaseActivity 中重寫即可)

@Override
public void onBackPressed() {
    if (transferLayout != null && transferLayout.isShown()) {
        transferLayout.dismiss();
    } else {
        super.onBackPressed();
    }
}

詳細示例代碼可以參考 TransferImageDemo

Attribute

屬性 說明
originImages 縮略圖 ImageView 數組
originImageList 縮略圖 ImageView 集合
originIndex 如果是一組縮略圖, originIndex 表示當前點擊的縮略圖下標位置, 否則 originIndex 默認為 0
offscreenPageLimit 顯示 TransferImage 時初始化加載的圖片數量, 默認為1, 表示第一次加載3張(originIndex, originIndex + 1, originIndex - 1); 值為 2, 表示加載5張。依次類推
backgroundColor TransferImage 背景色
missPlaceHolder 缺省的占位圖, 假設縮略圖為 N 張, 而 TransferImage 要顯示 N + 1 張高清圖, 那么 missPlaceHolder 表示為第 N + 1 張圖加載完成之前的占位圖
imageUrls 高清圖地址數組
imageUrlList 高清圖地址集合
transferAnima 從縮略圖到高清圖的過渡動畫 (默認內置 TransitionAnimator), 可自實現 ITransferAnimator 接口定義自己的過渡動畫
progressIndicat 加載高清圖的進度條 (默認內置 ProgressPieIndicator), 可自實現 IProgressIndicator 接口定義自己的圖片加載進度條
indexIndicator 圖片索引指示器 (默認內置 IndexCircleIndicator), 可自實現 IIndexIndicator 接口定義自己的圖片索引指示器
imageLoader 圖片加載器 (默認內置 GlideImageLoader), 可自實現 ImageLoader 接口定義自己的圖片加載器

Licence

Copyright 2016 Hitomis, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.</pre>

 

 

 

 本文由用戶 tpjc9094 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!