Warum reicht der Wert von X nicht bis zum Rand des Layouts?

palette2 Zeichenbar, das als Hintergrund verwendet wird:

esquare Zeichenbar (Größenänderung mit@dimen und als Daumen benutzt):

XML:

<LinearLayout
                android:id="@+id/llColorSpect"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:layout_alignParentBottom="true" >
                <RelativeLayout
                    android:id="@+id/rlColorSpect"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@drawable/palette2" >
                    <ImageView
                        android:id="@+id/ivSquare"
                        android:layout_width="@dimen/title_text_pad"
                        android:layout_height="@dimen/title_text_pad"
                        android:layout_alignParentBottom="true"
                        android:scaleType="fitXY"
                        android:src="@drawable/esquare" />
                </RelativeLayout>
            </LinearLayout>

Java:

llColors = (RelativeLayout) findViewById(R.id.rlColorSpect);
        llColors.setOnTouchListener(llTouch);

        bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.palette2);

        llColors.setBackground(getResources().getDrawable(R.drawable.palette2));

        w = bitmap.getWidth();
        h = bitmap.getHeight();

        Log.i("PALETTE WIDTH", "width" +w);
        Log.i("PALETTE HEIGHT", "height" +h);

        observer = llColors.getViewTreeObserver();
        observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                width = llColors.getWidth();
                height = llColors.getHeight();

                Log.i("LAYOUT WIDTH", "width" +width);
                Log.i("LAYOUT HEIGHT", "height" +height);
                //in here, place the code that requires you to know the dimensions.
                //Place your code here
            }
        });

View.OnTouchListener llTouch = new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            x = (int)event.getX();
            y = (int)event.getY();
            if (x<0) {
                ivTouch.setX(0);
                ivTouch.setY(y);
                x=0;
                Toast.makeText(getApplicationContext(), "x=0", 2000).show();
            }
            if (y<0) {
                ivTouch.setY(0);
                ivTouch.setX(x);
                y=0;
                Toast.makeText(getApplicationContext(), "y=0", 2000).show();
            }
            if (x>bitmap.getWidth()) {
                ivTouch.setX(bitmap.getWidth());
                x=bitmap.getWidth()-1;
                Toast.makeText(getApplicationContext(), "x=bitmap.maxwidth(}", 2000).show();
            }
            if (y>bitmap.getHeight()) {
                ivTouch.setY(bitmap.getHeight());
                y=bitmap.getHeight()-20;
                Toast.makeText(getApplicationContext(), "y=bitmap.maxheight(}", 2000).show();
            }
            if (x>0 && x<bitmap.getWidth() || y>0 || y<bitmap.getHeight()) {
                int action = event.getAction();
                int pixel = bitmap.getPixel((int)x,(int) y);

                switch (action & MotionEvent.ACTION_MASK) {
                    case MotionEvent.ACTION_DOWN: {
                        Log.i("COORDINATES","Touch coordinates : x" + String.valueOf(x) + "y" + String.valueOf(y));
                        ivTouch.setX(x);
                        ivTouch.setY(y);
                        inRed = Color.red(pixel);
                        inBlue = Color.blue(pixel);
                        inGreen = Color.green(pixel);
                        Log.d("Colors","R:" +inRed +" G:" +inGreen+" B:" + inBlue);
                        dispHVal(inRed, inGreen, inBlue);
                        hexToRGB();
                        break;
                    }
                    case MotionEvent.ACTION_MOVE:{
                        Log.i("COORDINATES","Touch coordinates : x" + String.valueOf(x) + "y" + String.valueOf(y));
                        ivTouch.setX(x);
                        ivTouch.setY(y);
                        inRed = Color.red(pixel);
                        inBlue = Color.blue(pixel);
                        inGreen = Color.green(pixel);
                        Log.d("Colors","R:" +inRed +" G:" +inGreen+" B:" + inBlue);
                        dispHVal(inRed, inGreen, inBlue);
                        hexToRGB();
                        break;
                    }
                }
            }
            return true;
        }
    };

Das LogCat zeigt Folgendes an:

01-31 22:55:38.729: I/LAYOUT WIDTH(23021): width660
01-31 22:55:38.729: I/LAYOUT HEIGHT(23021): height470
01-31 22:55:38.744: I/COORDINATES(23021): Touch coordinates : x579y89
01-31 22:55:38.744: D/Colors(23021): R:226 G:226 B:226
01-31 22:55:38.760: I/LAYOUT WIDTH(23021): width660
01-31 22:55:38.760: I/LAYOUT HEIGHT(23021): height470

Weiß jemand, warum ich nur auf 579 ziehen kann (das x geht nur auf 579), während die Layoutbreite 660 ist und wie kann ich das beheben?

BEARBEITEN: Ich möchte, dass der Benutzer an eine beliebige Stelle in der Liste ziehen kannRelativeLayout und wo der Benutzer zieht, bewegt sich der Daumen mit dem Finger, bleibt aber innerhalb des Layouts. Ich möchte in der Lage sein, den Hintergrund als Bitmap abzurufen, damit ich in RGB-Werte konvertieren kann. Wie mache ich das?

Antworten auf die Frage(1)

Ihre Antwort auf die Frage