MrWangChong / Dragphotoview
仿微信图片展示
Stars: ✭ 46
Programming Languages
java
68154 projects - #9 most used programming language
Labels
Projects that are alternatives of or similar to Dragphotoview
bubble-layout
An Android ViewGroup that displays avatar bubbles... similar to the chat bubbles on Facebook Messenger.
Stars: ✭ 46 (+0%)
Mutual labels: imageview
Imageviewer
🔮图片浏览器,支持图片手势缩放、拖拽等操作,`自定义View`的模式显示,自定义图片加载方式,更加灵活,易于扩展,同时也适用于RecyclerView、ListView的横向和纵向列表模式,最低支持版本为Android 3.0及以上...
Stars: ✭ 363 (+689.13%)
Mutual labels: imageview
Zoomlayout
2D zoom and pan behavior for View hierarchies, images, video streams, and much more, written in Kotlin for Android.
Stars: ✭ 688 (+1395.65%)
Mutual labels: imageview
imagin
An attachable image zooming library for the Android ImageView.
Stars: ✭ 17 (-63.04%)
Mutual labels: imageview
Windowview
Android ImageView you pan by tilting your device.
Stars: ✭ 269 (+484.78%)
Mutual labels: imageview
Continuousscrollableimageview
Library for animating images with continuous scrolling effects
Stars: ✭ 429 (+832.61%)
Mutual labels: imageview
Googlemapview
android google map view - imageView to make the map display process easier by entering latitude and longitude only by static map
Stars: ✭ 36 (-21.74%)
Mutual labels: imageview
Dragscalecircleview
a custom view that provides dragged and scaled
Stars: ✭ 513 (+1015.22%)
Mutual labels: imageview
Diagonal Imageview
A simple imageview which allows you to create diagonal cut views easily
Stars: ✭ 257 (+458.7%)
Mutual labels: imageview
Coloredshadowimageview
ColoredShadowImageView allows you to create a beautiful shadow around the image based on corresponding area colors.
Stars: ✭ 454 (+886.96%)
Mutual labels: imageview
TNImageView-Android
Android Library for making scale-able and rotatable image views or giving this power to your own image view. This repo has been depreciated.
Stars: ✭ 18 (-60.87%)
Mutual labels: imageview
Windowimageview
An ImageView display in RecyclerView, looks like window.
Stars: ✭ 699 (+1419.57%)
Mutual labels: imageview
easy-animated-vector-drawable
A library that helps using Animated Vector Drawables.
Stars: ✭ 40 (-13.04%)
Mutual labels: imageview
Avatarview
A circular Image View with a lot of perks. Including progress animation and highlight state with borders and gradient color.
Stars: ✭ 429 (+832.61%)
Mutual labels: imageview
Circular Music Progressbar
Beautiful Circular Progress Bar with album art for android
Stars: ✭ 813 (+1667.39%)
Mutual labels: imageview
图片展示界面
下载APK体验
引入
Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
compile 'com.github.MrWangChong:DragPhotoView:1.1.2'
}
这是从Wing神的DragPhotoView 基础上修改而来的,其中使用到了PhotoView 但是PhotoView 2.0.0在我的编译器上使用不了,强迫症要使用最新的我就把源码考了过来
图片加载使用了Google推荐的Glide
效果图
使用就参照ImageShowActivity就行
在我的适配器中声明了一个ImageView[] imageViews,如果是单张图片就不需要,如果是多张图片就要用数组把列表中的图片保存起来。
@Override
public void onBindViewHolder(ImageViewHolder viewHolder, int position) {
if (imageViews == null) {
imageViews = new ImageView[images.length];
}
imageViews[position] = viewHolder.image;
showImage(images[position], viewHolder.image);
final int currentPosition = position;
viewHolder.image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//List转[] --- List.toArray(new String[List.size()])
ImageShowActivity.startImageActivity((Activity) mContext, imageViews, images, currentPosition);
}
});
}
ImageShowActivity
public static void startImageActivity(Activity activity, ImageView imageView, String imageUrl) {
startImageActivity(activity, new ImageView[]{imageView}, new String[]{imageUrl}, 0);
}
public static void startImageActivity(Activity activity, ImageView[] imageViews, String[] imageUrls, int currentPosition) {
Intent intent = new Intent(activity, ImageShowActivity.class);
// ImageBean[] imageBeans = new ImageBean[imageViews.length];
ArrayList<ImageBean> imageBeans = new ArrayList<>();
for (ImageView imageView : imageViews) {
ImageBean imageBean = new ImageBean();
int location[] = new int[2];
imageView.getLocationOnScreen(location);
imageBean.left = location[0];
imageBean.top = location[1];
imageBean.width = imageView.getWidth();
imageBean.height = imageView.getHeight();
// imageBeans[i] = imageBean;
imageBeans.add(imageBean);
}
intent.putParcelableArrayListExtra("imageBeans", imageBeans);
intent.putExtra("currentPosition", currentPosition);
intent.putExtra("imageUrls", imageUrls);
activity.startActivity(intent);
activity.overridePendingTransition(0, 0);
}
这是ImageShowActivity里面的两个静态函数,跳转进来直接调用就行
因为点击返回键会有个结束动画,所以需要屏蔽多次点击返回键的事件,间隔时间最好是 动画时间3000秒
//设置不能在3秒内连续点击两次返回按钮
private long mExitTime;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if ((System.currentTimeMillis() - mExitTime) > 3000) {
mExitTime = System.currentTimeMillis();
} else {
return true;
}
}
return super.onKeyDown(keyCode, event);
}
一般展示图片都需要全屏,使用这个方法不会导致Activity重新排版
/**
* 不会导致Activity重新排版的全屏
*/
/*
关键是,在做了该Activity的全屏设置的前提下,还要在onCreate()方法中加入如下语句:
//将window扩展至全屏,并且不会覆盖状态栏
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
//避免在状态栏的显示状态发生变化时重新布局
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
*/
private void setIsShowStatusBar(boolean show) {
isShowStatusBar = show;
if (show) {
//显示
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
} else {
//隐藏
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
}
}
/**
* 显示图片
*/
public void showImage(String url, ImageView imageView) {
if (!TextUtils.isEmpty(url) && url.length() > 0) {
url = url.replaceAll(" ", "");
}
if (TextUtils.isEmpty(url)) {
return;
}
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
imageView.setAdjustViewBounds(true);
Glide.with(this).load(url)
.dontAnimate()
.placeholder(R.mipmap.ic_loding_error)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.error(R.mipmap.ic_loding_error)
.into(imageView);
// Picasso.with(this).load(url)
// .error(R.mipmap.ic_loding_error)
// .into(imageView);
}
还需要把Activity的主题设置为透明 manifest配置
<!-- 显示图片界面 -->
<activity
android:name=".activity.ImageShowActivity"
android:screenOrientation="portrait"
android:theme="@style/translucent" />
styles配置
<resources>
<style name="translucent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
</style>
</resources>
总而言之,如果没有特殊需求,就把ImageShowActivity拷贝过来使用就行了
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].