마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

배경색깔 바꿔주는 부분 캐치좀 해주세요 ㅠㅠ

0 추천

 

 

소스랑 화면 입니다.

화면배경이 하얀색으로 나오는데 검은색으로 만들고싶은데 

어떤부분을 바꿔도 바뀌지가않네요 ㅠㅠ

255,255,255 인부분 0,0,0으로 바꿔도 안되고 ㅠㅠ

 

 

 

public MyView(Context c) {
            super(c);
            mTextPaint = new Paint();
            mTextPaint.setAntiAlias(true);
            mTextPaint.setTextSize(10);
            mTextPaint.setARGB(255, 0, 0, 0);
            mTextBackgroundPaint = new Paint();
            mTextBackgroundPaint.setAntiAlias(false);
            mTextBackgroundPaint.setARGB(128, 255, 255, 255);
            mTextLevelPaint = new Paint();
            mTextLevelPaint.setAntiAlias(false);
            mTextLevelPaint.setARGB(192, 255, 0, 0);
            mPaint = new Paint();
            mPaint.setAntiAlias(true);
            mPaint.setARGB(255, 255, 255, 255);
            mPaint.setStyle(Paint.Style.STROKE);
            mPaint.setStrokeWidth(2);
            mTargetPaint = new Paint();
            mTargetPaint.setAntiAlias(false);
            mTargetPaint.setARGB(192, 0, 0, 255);
            mPaint.setStyle(Paint.Style.STROKE);
            mPaint.setStrokeWidth(1);
        }

        @Override
        protected void onDraw(Canvas canvas) {
            int w = getWidth()/5;
            int base = -mTextMetrics.ascent+1;
            int bottom = mHeaderBottom;
            canvas.drawRect(0, 0, w-1, bottom, mTextBackgroundPaint);
            canvas.drawText("X: " + mCurX, 1, base, mTextPaint);
            canvas.drawRect(w, 0, (w * 2) - 1, bottom, mTextBackgroundPaint);
            canvas.drawText("Y: " + mCurY, 1 + w, base, mTextPaint);
            canvas.drawRect(w * 2, 0, (w * 3) - 1, bottom, mTextBackgroundPaint);
            canvas.drawRect(w * 2, 0, (w * 2) + (mCurPressure * w) - 1, bottom, mTextLevelPaint);
            canvas.drawText("Pres: " + mCurPressure, 1 + w * 2, base, mTextPaint);
            canvas.drawRect(w * 3, 0, (w * 4) - 1, bottom, mTextBackgroundPaint);
            canvas.drawRect(w * 3, 0, (w * 3) + (mCurSize * w) - 1, bottom, mTextLevelPaint);
            canvas.drawText("Size: " + mCurSize, 1 + w * 3, base, mTextPaint);
            canvas.drawRect(w * 4, 0, getWidth(), bottom, mTextBackgroundPaint);
            int velocity = mVelocity == null ? 0 : (int) (mVelocity.getYVelocity() * 1000);
            canvas.drawText("yVel: " + velocity, 1 + w * 4, base, mTextPaint);

            final int N = mXs.size();
            float lastX=0, lastY=0;
            mPaint.setARGB(255, 0, 255, 255);
            for (int i=0; i<N; i++) {
                float x = mXs.get(i);
                float y = mYs.get(i);
                if (i > 0) {
                    canvas.drawLine(lastX, lastY, x, y, mTargetPaint);
                    canvas.drawPoint(lastX, lastY, mPaint);
                }
                lastX = x;
                lastY = y;
            }
            if (mVelocity != null) {
                mPaint.setARGB(255, 255, 0, 0);
                float xVel = mVelocity.getXVelocity() * (1000/60);
                float yVel = mVelocity.getYVelocity() * (1000/60);
                canvas.drawLine(lastX, lastY, lastX+xVel, lastY+yVel, mPaint);
            } else {
                canvas.drawPoint(lastX, lastY, mPaint);
            }

            if (mCurDown) {
                canvas.drawLine(0, (int)mCurY, getWidth(), (int)mCurY, mTargetPaint);
                canvas.drawLine((int)mCurX, 0, (int)mCurX, getHeight(), mTargetPaint);
                int pressureLevel = (int)(mCurPressure*255);
                mPaint.setARGB(255, pressureLevel, 128, 255-pressureLevel);
                canvas.drawPoint(mCurX, mCurY, mPaint);
                canvas.drawCircle(mCurX, mCurY, mCurWidth, mPaint);
            }
        }

익명사용자 님이 2015년 12월 3일 질문

1개의 답변

0 추천
만약에 상속을 Veiw 계열 받으셧다면

 this.setBackgroundColor();를 한번사용해보세요.
전판진 (240 포인트) 님이 2015년 12월 4일 답변
...