Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java NineodelDroid库使视图不稳定 private void createnewpattern(最终字符串res){ 最终整型宽度、高度; BitmapDrawable图像=空; if(res.equals(“”){ 宽度=位图.getWidth(); 高度=位图.getHeight(); }否则{ image=(BitmapDrawable)this.getResources().getDrawable( getResources().getIdentifier(res,“可绘制”, getPackageName()); 宽度=image.getBitmap().getWidth(); 高度=image.getBitmap().getHeight(); } ImageView模式=新的ImageView(此模式); 模式设置ID(起始编号); if(res.equals(“”) 设置图像位图(位图); 其他的 模式。可设置图像绘制(图像); 模式.设置刻度类型(刻度类型.配合中心); 图案。设置填充(宽度/4,高度/4,宽度/4,高度/4); 最终RelativeLayout.LayoutParams patternparam=新的RelativeLayout.LayoutParams( 宽度*3/2,高度*3/2); 随机=新随机(); int rx=random.nextInt((contentimage.getWidth()*3/4) -getWidth()/4+1)+0; int ry=random.nextInt((contentimage.getHeight()*3/4) -contentimage.getHeight()/4+1)+0; if(res.equals(“”) patternparam.setMargins(GlobalFunction.leftmargin-宽度/4, GlobalFunction.topmargin-高度/4,0,0); 其他的 patternparam.setMargins(rx,ry,0,0); pattern.setOnTouchListener(新的OnTouchListener(){ @凌驾 公共布尔onTouch(视图、运动事件){ if(isselected.get(view.getId()-1001)){ mScaleDetector.onTouchEvent(事件); mRotateDetector.onTouchEvent(事件); mMoveDetector.onTouchEvent(事件); ImageView ImageView=(ImageView)rLayout .findViewById(选择EdId); 设置旋转(imageview,mRotationDegrees); ViewHelper.setScaleX(图像视图,mScaleFactor); ViewHelper.setScaleY(图像视图,mScaleFactor); setTranslationX(imageview,mFocusX); setTranslationY(imageview,mFocusY); } 开关(event.getAction()&MotionEvent.ACTION\u掩码){ case MotionEvent.ACTION\u UP: 如果(!isselected.get(view.getId()-1001)){ 对于(int j=0;j_Java_Android_Viewhelper - Fatal编程技术网

Java NineodelDroid库使视图不稳定 private void createnewpattern(最终字符串res){ 最终整型宽度、高度; BitmapDrawable图像=空; if(res.equals(“”){ 宽度=位图.getWidth(); 高度=位图.getHeight(); }否则{ image=(BitmapDrawable)this.getResources().getDrawable( getResources().getIdentifier(res,“可绘制”, getPackageName()); 宽度=image.getBitmap().getWidth(); 高度=image.getBitmap().getHeight(); } ImageView模式=新的ImageView(此模式); 模式设置ID(起始编号); if(res.equals(“”) 设置图像位图(位图); 其他的 模式。可设置图像绘制(图像); 模式.设置刻度类型(刻度类型.配合中心); 图案。设置填充(宽度/4,高度/4,宽度/4,高度/4); 最终RelativeLayout.LayoutParams patternparam=新的RelativeLayout.LayoutParams( 宽度*3/2,高度*3/2); 随机=新随机(); int rx=random.nextInt((contentimage.getWidth()*3/4) -getWidth()/4+1)+0; int ry=random.nextInt((contentimage.getHeight()*3/4) -contentimage.getHeight()/4+1)+0; if(res.equals(“”) patternparam.setMargins(GlobalFunction.leftmargin-宽度/4, GlobalFunction.topmargin-高度/4,0,0); 其他的 patternparam.setMargins(rx,ry,0,0); pattern.setOnTouchListener(新的OnTouchListener(){ @凌驾 公共布尔onTouch(视图、运动事件){ if(isselected.get(view.getId()-1001)){ mScaleDetector.onTouchEvent(事件); mRotateDetector.onTouchEvent(事件); mMoveDetector.onTouchEvent(事件); ImageView ImageView=(ImageView)rLayout .findViewById(选择EdId); 设置旋转(imageview,mRotationDegrees); ViewHelper.setScaleX(图像视图,mScaleFactor); ViewHelper.setScaleY(图像视图,mScaleFactor); setTranslationX(imageview,mFocusX); setTranslationY(imageview,mFocusY); } 开关(event.getAction()&MotionEvent.ACTION\u掩码){ case MotionEvent.ACTION\u UP: 如果(!isselected.get(view.getId()-1001)){ 对于(int j=0;j

Java NineodelDroid库使视图不稳定 private void createnewpattern(最终字符串res){ 最终整型宽度、高度; BitmapDrawable图像=空; if(res.equals(“”){ 宽度=位图.getWidth(); 高度=位图.getHeight(); }否则{ image=(BitmapDrawable)this.getResources().getDrawable( getResources().getIdentifier(res,“可绘制”, getPackageName()); 宽度=image.getBitmap().getWidth(); 高度=image.getBitmap().getHeight(); } ImageView模式=新的ImageView(此模式); 模式设置ID(起始编号); if(res.equals(“”) 设置图像位图(位图); 其他的 模式。可设置图像绘制(图像); 模式.设置刻度类型(刻度类型.配合中心); 图案。设置填充(宽度/4,高度/4,宽度/4,高度/4); 最终RelativeLayout.LayoutParams patternparam=新的RelativeLayout.LayoutParams( 宽度*3/2,高度*3/2); 随机=新随机(); int rx=random.nextInt((contentimage.getWidth()*3/4) -getWidth()/4+1)+0; int ry=random.nextInt((contentimage.getHeight()*3/4) -contentimage.getHeight()/4+1)+0; if(res.equals(“”) patternparam.setMargins(GlobalFunction.leftmargin-宽度/4, GlobalFunction.topmargin-高度/4,0,0); 其他的 patternparam.setMargins(rx,ry,0,0); pattern.setOnTouchListener(新的OnTouchListener(){ @凌驾 公共布尔onTouch(视图、运动事件){ if(isselected.get(view.getId()-1001)){ mScaleDetector.onTouchEvent(事件); mRotateDetector.onTouchEvent(事件); mMoveDetector.onTouchEvent(事件); ImageView ImageView=(ImageView)rLayout .findViewById(选择EdId); 设置旋转(imageview,mRotationDegrees); ViewHelper.setScaleX(图像视图,mScaleFactor); ViewHelper.setScaleY(图像视图,mScaleFactor); setTranslationX(imageview,mFocusX); setTranslationY(imageview,mFocusY); } 开关(event.getAction()&MotionEvent.ACTION\u掩码){ case MotionEvent.ACTION\u UP: 如果(!isselected.get(view.getId()-1001)){ 对于(int j=0;j,java,android,viewhelper,Java,Android,Viewhelper,我有这个监听器,但有一些错误 图像的方向也将旋转 当我旋转90度时,我向上平移Y,但图像向左平移X。听起来就像旋转90度时,视图的方向也改变了,因此Y轴变成了用户看到的X轴。你能提供实际旋转和平移的动画代码吗 private void createnewpattern(final String res) { final int width, height; BitmapDrawable image = null; if (res.equals("")) {

我有这个监听器,但有一些错误

图像的方向也将旋转


当我旋转90度时,我向上平移Y,但图像向左平移X。

听起来就像旋转90度时,视图的方向也改变了,因此Y轴变成了用户看到的X轴。你能提供实际旋转和平移的动画代码吗

private void createnewpattern(final String res) {
    final int width, height;
    BitmapDrawable image = null;
    if (res.equals("")) {
        width = bitmap.getWidth();
        height = bitmap.getHeight();
    } else {
        image = (BitmapDrawable) this.getResources().getDrawable(
                getResources().getIdentifier(res, "drawable",
                        getPackageName()));
        width = image.getBitmap().getWidth();
        height = image.getBitmap().getHeight();
    }

    ImageView pattern = new ImageView(this);
    pattern.setId(startingnumber);
    if (res.equals(""))
        pattern.setImageBitmap(bitmap);
    else
        pattern.setImageDrawable(image);
    pattern.setScaleType(ScaleType.FIT_CENTER);

    pattern.setPadding(width / 4, height / 4, width / 4, height / 4);

    final RelativeLayout.LayoutParams patternparam = new RelativeLayout.LayoutParams(
            width * 3 / 2, height * 3 / 2);

    Random random = new Random();
    int rx = random.nextInt((contentimage.getWidth() * 3 / 4)
            - contentimage.getWidth() / 4 + 1) + 0;
    int ry = random.nextInt((contentimage.getHeight() * 3 / 4)
            - contentimage.getHeight() / 4 + 1) + 0;

    if (res.equals(""))
        patternparam.setMargins(GlobalFunction.leftmargin - width / 4,
                GlobalFunction.topmargin - height / 4, 0, 0);
    else
        patternparam.setMargins(rx, ry, 0, 0);

    pattern.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent event) {
            if (isselected.get(view.getId() - 1001)) {

                mScaleDetector.onTouchEvent(event);

                mRotateDetector.onTouchEvent(event);

                mMoveDetector.onTouchEvent(event);

                ImageView imageview = (ImageView) rLayout
                        .findViewById(selectedid);

                ViewHelper.setRotation(imageview, mRotationDegrees);

                ViewHelper.setScaleX(imageview, mScaleFactor);
                ViewHelper.setScaleY(imageview, mScaleFactor);

                ViewHelper.setTranslationX(imageview, mFocusX);
                ViewHelper.setTranslationY(imageview, mFocusY);
            }

            switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_UP:
                if (!isselected.get(view.getId() - 1001)) {
                    for (int j = 0; j < isselected.size(); j++) {
                        isselected.set(j, false);
                        rLayout.findViewById(1001 + j)
                                .setBackgroundDrawable(null);
                    }

                    selectedid = view.getId();
                    isselected.set(view.getId() - 1001, true);
                    view.setBackgroundResource(R.drawable.border);

                    ImageView imageview = (ImageView) view;
                    imageview.setScaleType(ScaleType.FIT_CENTER);
                    imageview.setPadding(width / 4, height / 4, width / 4,
                            height / 4);

                    mScaleFactor = ViewHelper.getScaleX(imageview);

                    mRotationDegrees = ViewHelper.getRotation(imageview);

                    mFocusX = ViewHelper.getTranslationX(imageview);
                    mFocusY = ViewHelper.getTranslationY(imageview);
                }
                break;
            }

            return true;
        }
    });

    patternframe.addView(pattern, patternparam);

    isselected.add(false);
    startingnumber++;

    action4btn.setBackgroundDrawable(GlobalFunction.backgroundselector(
            this, R.drawable.paint_action_4_default,
            R.drawable.paint_action_4_selected));
}

private class ScaleListener extends
        ScaleGestureDetector.SimpleOnScaleGestureListener {
    @Override
    public boolean onScale(ScaleGestureDetector detector) {
        mScaleFactor *= detector.getScaleFactor();
        mScaleFactor = Math.max(0.5f, Math.min(mScaleFactor, 4f));

        return true;
    }
}

private class OnRotationGestureListener implements
        RotationGestureDetector.OnRotationGestureListener {

    @Override
    public boolean OnRotation(RotationGestureDetector rotationDetector) {
        mRotationDegrees -= rotationDetector.getAngle();

        return true;
    }
}

private class MoveListener extends
        MoveGestureDetector.SimpleOnMoveGestureListener {
    @Override
    public boolean onMove(MoveGestureDetector detector) {
        PointF d = detector.getFocusDelta();
        mFocusX += d.x;
        mFocusY += d.y;

        return true;
    }
}