PhotoView+Glide+Dialog+ViewPager:打造轻量级的图片浏览方案 其实不单单是做简单的图片浏览、android原生的dialog可以做到activity、fragment的大部分展示功能,而且更轻量化,易于封装与维护。
* 为了解决photoview嵌套在部分父控件时闪退的bug,github上提供的解决方案
*/
public class ShowImagesViewPager extends ViewPager {
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
try {
return super.onInterceptTouchEvent(ev);
} catch (IllegalArgumentException e) {
//uncomment if you really want to see these errors
//e.printStackTrace();
return false;
}
}
}
<style name="transparentBgDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:background">@color/transparent</item>
<item name="android:windowNoTitle">true</item>
</style>
dialog正常显示photoview
同一张图片缩放后的photoview