本文整理匯總了Java中uk.co.senab.photoview.PhotoView.setLayoutParams方法的典型用法代碼示例。如果您正苦於以下問題:Java PhotoView.setLayoutParams方法的具體用法?Java PhotoView.setLayoutParams怎麽用?Java PhotoView.setLayoutParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類uk.co.senab.photoview.PhotoView
的用法示例。
在下文中一共展示了PhotoView.setLayoutParams方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initViewPager
import uk.co.senab.photoview.PhotoView; //導入方法依賴的package包/類
/**
* 初始化ViewPager
*/
private void initViewPager() {
for (String url : imgList) {
PhotoView photoView = new PhotoView(context);
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
photoView.setLayoutParams(lp);
Glide.with(context).load(url)
.fitCenter()
.thumbnail(0.1f)
.into(photoView);
viewList.add(photoView);
viewPager.setCurrentItem(index);
tv_index.setText((index + 1) + "/" + imgList.size());
}
adapter = new GalleryAdapter(viewList);
viewPager.setAdapter(adapter);
viewPager.setOffscreenPageLimit(2);
viewPager.addOnPageChangeListener(this);
}
示例2: showBig
import uk.co.senab.photoview.PhotoView; //導入方法依賴的package包/類
public static void showBig(final PhotoView iv , DataBean.PicBean pic){
resizeImage(iv,pic);
iv.setScaleType(ImageView.ScaleType.FIT_XY);
if(getType(pic.file.type).contains("gif")){
//iv.setZoomable(false);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)iv.getLayoutParams();
params.gravity = Gravity.CENTER;
iv.setLayoutParams(params);
baseGif(iv,Api.HOST_PIC+pic.file.key).into(iv);
}else{
iv.setZoomable(true);
iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
Glide.with(iv.getContext())
.load(Api.HOST_PIC+pic.file.key)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.placeholder(getRandomColor())
.into(new SimpleTarget<Bitmap>() {
@Override
public void onStart() {
iv.setImageResource(getRandomColor());
}
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
// LogUtils.d("size of big :"+resource.getHeight()+"*"+resource.getWidth());
if (resource.getWidth() < resource.getHeight() && resource.getHeight() > MAX_HEIGHT_HEIGHT) {
iv.setImageBitmap(Bitmap.createScaledBitmap(resource, resource.getWidth() * MAX_HEIGHT_HEIGHT / resource.getHeight(), MAX_HEIGHT_HEIGHT, true));
} else if (resource.getWidth() > resource.getHeight() && resource.getWidth() > MAX_HEIGHT_HEIGHT) {
iv.setImageBitmap(Bitmap.createScaledBitmap(resource, MAX_HEIGHT_HEIGHT, resource.getHeight() * MAX_HEIGHT_HEIGHT / resource.getWidth(), true));
} else {
iv.setImageBitmap(resource);
}
}
});
}
}
示例3: instantiateItem
import uk.co.senab.photoview.PhotoView; //導入方法依賴的package包/類
@Override
public View instantiateItem(ViewGroup container, int position) {
PhotoView photoView = new PhotoView(container.getContext());
photoView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
String imgPath = (String)getItem(position);
mImageLoader.displayImage(FileUtil.getFormatFilePath(imgPath), (ImageView)photoView,
mOptions, null);
// Now just add PhotoView to ViewPager and return it
container.addView(photoView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
return photoView;
}
示例4: init
import uk.co.senab.photoview.PhotoView; //導入方法依賴的package包/類
public void init(){
if (animator != null) {
animator.cancel();
}
container = (ContentFrameLayout) activity.findViewById(android.R.id.content);
copyImageView = new PhotoView(activity);
int matchParent = FrameLayout.LayoutParams.MATCH_PARENT;
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(matchParent, matchParent);
copyImageView.setLayoutParams(params);
r = new RelativeLayout(activity);
r.setLayoutParams(params);
r.setBackgroundColor(Color.BLACK);
if (originalView instanceof ImageView) {
copyImageView.setImageDrawable(((ImageView) originalView).getDrawable());
} else {
Bitmap bm = view2Bitmap(originalView);
if (bm != null) {
copyImageView.setImageBitmap(bm);
}
}
copyImageView.setVisibility(View.GONE);
r.setVisibility(View.GONE);
container.addView(r);
container.addView(copyImageView);
startRect = new Rect();
endRect = new Rect();
Point offsetPoint = new Point();
originalView.getGlobalVisibleRect(startRect);
/**
* r 是 絕對(global)坐標參數,包含狀態欄、ActionBar、底部虛擬鍵
* globalOffset 用於將global坐標轉換成local坐標,這裏的local坐標,是相對於內容區的坐標,也就是除了狀態欄和action bar和虛擬按鍵的區域。
* */
container.getGlobalVisibleRect(endRect, offsetPoint);
startRect.offset(-offsetPoint.x, -offsetPoint.y);
endRect.offset(-offsetPoint.x, -offsetPoint.y);
float scaleSize;
float startScaleFinal;
Log.d("garyhu","width == "+endRect.width());
Log.d("garyhu","height == "+endRect.height());
if ((float) endRect.width() / (float) endRect.height() > (float) startRect.width() / (float) startRect.height()) {
startScale = (float) startRect.height() / (float) endRect.height();
scaleSize = startScale * (float) endRect.width();
startScaleFinal = (scaleSize - (float) startRect.width()) / 2.0F;
startRect.left = (int) ((float) startRect.left - startScaleFinal);
startRect.right = (int) ((float) startRect.right + startScaleFinal);
} else {
startScale = (float) startRect.width() / (float) endRect.width();
scaleSize = startScale * (float) endRect.height();
startScaleFinal = (scaleSize - (float) startRect.height()) / 2.0F;
startRect.top = (int) ((float) startRect.top - startScaleFinal);
startRect.bottom = (int) ((float) startRect.bottom + startScaleFinal);
}
}