Search in sources :

Example 81 with RelativeLayout

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;
}
Also used : RelativeLayout(android.widget.RelativeLayout) ImageView(android.widget.ImageView) View(android.view.View) ScrollView(android.widget.ScrollView)

Example 82 with RelativeLayout

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);
}
Also used : RelativeLayout(android.widget.RelativeLayout)

Example 83 with RelativeLayout

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;
}
Also used : RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) View(android.view.View)

Example 84 with RelativeLayout

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);
}
Also used : Bitmap(android.graphics.Bitmap) RelativeLayout(android.widget.RelativeLayout) GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation)

Example 85 with RelativeLayout

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();
}
Also used : Context(android.content.Context) Rect(android.graphics.Rect) StackTransitionAnimator(com.nu.art.cyborg.core.CyborgStackController.StackTransitionAnimator) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) FrameLayout(android.widget.FrameLayout) AnimatorListenerImpl(com.nu.art.cyborg.common.implementors.AnimatorListenerImpl) RelativeLayout(android.widget.RelativeLayout) AnimatorSet(android.animation.AnimatorSet) ImageView(android.widget.ImageView)

Aggregations

RelativeLayout (android.widget.RelativeLayout)396 TextView (android.widget.TextView)180 View (android.view.View)164 ImageView (android.widget.ImageView)109 LinearLayout (android.widget.LinearLayout)67 ViewGroup (android.view.ViewGroup)61 Intent (android.content.Intent)31 AdapterView (android.widget.AdapterView)29 Button (android.widget.Button)29 FrameLayout (android.widget.FrameLayout)28 SuppressLint (android.annotation.SuppressLint)26 LayoutInflater (android.view.LayoutInflater)22 OnClickListener (android.view.View.OnClickListener)22 ScrollView (android.widget.ScrollView)22 Paint (android.graphics.Paint)20 CardView (android.support.v7.widget.CardView)19 Context (android.content.Context)18 Point (android.graphics.Point)18 ListView (android.widget.ListView)18 RadioButton (android.widget.RadioButton)17