Java 如果用户向左或向右按太多,则应用程序为FC
我有以下XML:Java 如果用户向左或向右按太多,则应用程序为FC,java,android,eclipse,android-layout,Java,Android,Eclipse,Android Layout,我有以下XML: <LinearLayout android:id="@+id/llColorSpect" android:layout_width="match_parent" android:layout_height="@dimen/color_scheme_height" android:orientation="vertical" android:background="@drawable/colorspect" android:l
<LinearLayout
android:id="@+id/llColorSpect"
android:layout_width="match_parent"
android:layout_height="@dimen/color_scheme_height"
android:orientation="vertical"
android:background="@drawable/colorspect"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginBottom="@dimen/seek_bar_margin"
android:layout_below="@+id/tvBGColor" >
<RelativeLayout
android:id="@+id/rlColorSpect"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<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>
我遇到的问题
View.OnTouchListener llTouch = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int x = (int)event.getX();
int y = (int)event.getY();
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);
int redValue = Color.red(pixel);
int blueValue = Color.blue(pixel);
int greenValue = Color.green(pixel);
Log.d("Colors","R:" +redValue +" G:" +greenValue+" B:" + blueValue);
sbRed.setProgress(redValue);
sbGreen.setProgress(greenValue);
sbBlue.setProgress(blueValue);
dispHVal();
break;
}
case MotionEvent.ACTION_MOVE:{
Log.i("COORDINATES","Touch coordinates : x" + String.valueOf(x) + "y" + String.valueOf(y));
ivTouch.setX(x);
ivTouch.setY(y);
int redValue = Color.red(pixel);
int blueValue = Color.blue(pixel);
int greenValue = Color.green(pixel);
Log.d("Colors","R:" +redValue +" G:" +greenValue+" B:" + blueValue);
sbRed.setProgress(redValue);
sbGreen.setProgress(greenValue);
sbBlue.setProgress(blueValue);
dispHVal();
break;
}
}
return true;
}
};