use of android.widget.RelativeLayout in project XRichText by sendtion.
the class RichTextEditor method createImageLayout.
/**
* 生成图片View
*/
private RelativeLayout createImageLayout() {
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.edit_imageview, null);
layout.setTag(viewTagIndex++);
View closeView = layout.findViewById(R.id.image_close);
// closeView.setVisibility(GONE);
closeView.setTag(layout.getTag());
closeView.setOnClickListener(btnListener);
View imageView = layout.findViewById(R.id.edit_imageView);
imageView.setOnClickListener(btnListener);
return layout;
}
use of android.widget.RelativeLayout in project XRichText by sendtion.
the class RichTextEditor method addImageViewAtIndex.
/**
* 在特定位置添加ImageView
*/
public void addImageViewAtIndex(final int index, Bitmap bmp, String imagePath) {
imagePaths.add(imagePath);
RelativeLayout imageLayout = createImageLayout();
DataImageView imageView = (DataImageView) imageLayout.findViewById(R.id.edit_imageView);
Glide.with(getContext()).load(imagePath).crossFade().centerCrop().into(imageView);
imageView.setAbsolutePath(imagePath);
// 裁剪剧中
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
// 调整imageView的高度,根据宽度等比获得高度
// int imageHeight = allLayout.getWidth() * bmp.getHeight() / bmp.getWidth();
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, // TODO 固定图片高度500,考虑自定义属性
500);
lp.bottomMargin = 10;
imageView.setLayoutParams(lp);
// onActivityResult无法触发动画,此处post处理
allLayout.addView(imageLayout, index);
// allLayout.postDelayed(new Runnable() {
// @Override
// public void run() {
// allLayout.addView(imageLayout, index);
// }
// }, 200);
}
use of android.widget.RelativeLayout in project XRichText by sendtion.
the class RichTextView method createImageLayout.
/**
* 生成图片View
*/
private RelativeLayout createImageLayout() {
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.edit_imageview, null);
layout.setTag(viewTagIndex++);
View closeView = layout.findViewById(R.id.image_close);
closeView.setVisibility(GONE);
View imageView = layout.findViewById(R.id.edit_imageView);
// imageView.setTag(layout.getTag());
imageView.setOnClickListener(btnListener);
return layout;
}
use of android.widget.RelativeLayout in project XRichText by sendtion.
the class RichTextView method addImageViewAtIndex.
/**
* 在特定位置添加ImageView
*/
public void addImageViewAtIndex(final int index, final String imagePath) {
imagePaths.add(imagePath);
RelativeLayout imageLayout = createImageLayout();
final DataImageView imageView = (DataImageView) imageLayout.findViewById(R.id.edit_imageView);
imageView.setAbsolutePath(imagePath);
// 如果是网络图片
if (imagePath.startsWith("http")) {
Glide.with(getContext()).load(imagePath).asBitmap().dontAnimate().into(new SimpleTarget<Bitmap>(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
// 调整imageView的高度,根据宽度等比获得高度
int imageHeight = allLayout.getWidth() * resource.getHeight() / resource.getWidth();
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, // 固定图片高度,记得设置裁剪剧中
imageHeight);
lp.bottomMargin = 10;
imageView.setLayoutParams(lp);
Glide.with(getContext()).load(imagePath).crossFade().centerCrop().placeholder(R.drawable.img_load_fail).error(R.drawable.img_load_fail).override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).into(imageView);
}
});
} else {
// 如果是本地图片
Bitmap bmp = BitmapFactory.decodeFile(imagePath);
// 调整imageView的高度,根据宽度等比获得高度
int imageHeight = allLayout.getWidth() * bmp.getHeight() / bmp.getWidth();
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, // 固定图片高度,记得设置裁剪剧中
imageHeight);
lp.bottomMargin = 10;
imageView.setLayoutParams(lp);
Glide.with(getContext()).load(imagePath).crossFade().centerCrop().placeholder(R.drawable.img_load_fail).error(R.drawable.img_load_fail).into(imageView);
}
// onActivityResult无法触发动画,此处post处理
allLayout.addView(imageLayout, index);
}
use of android.widget.RelativeLayout in project cyborg-core by nu-art.
the class FloatingViewTransitionAnimator method renderFromTo.
private void renderFromTo(View fromParent, final View viewToAnimateFrom, final View viewToAnimateTo, Bitmap imageToAnimate, int duration, final AnimationListener listener) {
final FrameLayout rootView = (FrameLayout) fromParent.getRootView().findViewById(android.R.id.content);
Context context = rootView.getContext();
final RelativeLayout renderingLayer = new RelativeLayout(context);
renderingLayer.setClipChildren(false);
rootView.addView(renderingLayer);
final ImageView imageView = new ImageView(context);
imageView.setImageBitmap(imageToAnimate);
renderingLayer.addView(imageView);
AnimatorSet animationSet = new AnimatorSet();
animationSet.addListener(new AnimatorListenerImpl() {
@Override
public void onAnimationStart(Animator animator) {
// the origin view should remain a bit longer to avoid the transition hiccup between the original view and the image to be animated...
viewToAnimateFrom.post(new Runnable() {
@Override
public void run() {
viewToAnimateFrom.setVisibility(View.INVISIBLE);
}
});
// the target view should be hidden from the get go!
viewToAnimateTo.setVisibility(View.INVISIBLE);
}
@Override
public void onAnimationEnd(Animator animator) {
rootView.removeView(renderingLayer);
viewToAnimateTo.setVisibility(View.VISIBLE);
if (listener != null)
listener.onAnimationEnd(null);
}
});
// extract the view real area's on screen
Rect originRect = Tools.getViewRealRect(viewToAnimateFrom);
Rect targetRect = Tools.getViewRealRect(viewToAnimateTo);
imageView.setTranslationX(originRect.left);
imageView.setTranslationY(originRect.top);
Animator translateX = ObjectAnimator.ofFloat(imageView, "translationX", targetRect.left);
Animator translateY = ObjectAnimator.ofFloat(imageView, "translationY", targetRect.top);
Animator animateW = ValueAnimator.ofObject(new WidthEvaluator(imageView), originRect.width(), targetRect.width());
Animator animateH = ValueAnimator.ofObject(new HeightEvaluator(imageView), originRect.height(), targetRect.height());
animationSet.setDuration(duration);
animationSet.playTogether(translateX, translateY, animateW, animateH);
animationSet.start();
}
Aggregations