我有以下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: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>
我的部分Java代码:
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;
}
};
我遇到的问题。
01-25 01:13:21.059:E / AndroidRuntime(13345):致命例外:主要01-25 01:13:21.059:E /
AndroidRuntime(13345):java.lang.IllegalArgumentException:x必须<bitmap.width(
)01-25 01:13:21.059:E /
AndroidRuntime(13345):在android.graphics.Bitmap.checkPixelAccess(Bitmap.java:1155)01-25
01:13:21.059:E / AndroidRuntime(13345):在Android
.graphics.Bitmap.getPixel(Bitmap.java:1107)01-25 01:13:21.059:E /
AndroidRuntime(13345):at com.test.testing.MainActivity $
1.onTouch(MainActivity.java:98)01-25 01:13:21.059:E /
AndroidRuntime(13345):在android.view.View.dispatchTouchEvent(View.java:7241)01-25
01:13:21.059:E / AndroidRuntime(13345):在android.view.ViewGroup
.dispatchTransformedTouchEvent(ViewGroup.java:2168)01-25 01:13:21.059:E /
AndroidRuntime(13345):位于android.view.ViewGroup.dispatchTouchEvent(ViewGroup。java:1903)01-25
01:13:21.059:E /
AndroidRuntime(13345):位于android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)01-25
01:13:21.059:E / AndroidRuntime(13345)
:位于android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1875)01-25
01:13:21.059:E /
AndroidRuntime(13345):位于android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)01-25
01:13:21.059:E /
AndroidRuntime(13345):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1875)01-25
01:13:21.059:E / AndroidRuntime(13345):在android.view.ViewGroup
.dispatchTransformedTouchEvent(ViewGroup.java:2174)01-25 01:13:21.059:E /
AndroidRuntime(13345):at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1875)01-25
01:13:21.059:E /
AndroidRuntime(13345):位于android.view.ViewGroup。dispatchTransformedTouchEvent(ViewGroup.java:2174)01-25
01:13:21.059:E / AndroidRuntime(13345):at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1875)01-25
01:13:21.059:E /
AndroidRuntime(13345):在com.android.internal.policy.impl.PhoneWindow $
DecorView.superDispatchTouchEvent(PhoneWindow.java:1953)01-25 01:13:21.059:E
/ AndroidRuntime(13345):在com.android.internal
.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1405)01-25
01:13:21.059:E / AndroidRuntime(13345):at
android.app.Activity.dispatchTouchEvent(Activity.java:2410)01-25 01
:13:21.059:E /
AndroidRuntime(13345):在com.android.internal.policy.impl.PhoneWindow $
DecorView.dispatchTouchEvent(PhoneWindow.java:1901)01-25 01:13:21.059:E /
AndroidRuntime(13345)
:位于android.view.View.dispatchPointerEvent(View.java:7426)01-25
01:13:21。059:E /
AndroidRuntime(13345):位于android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3220)01-25
01:13:21.059:E /
AndroidRuntime(13345):位于android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl
.java:3165)01-25 01:13:21.059:E /
AndroidRuntime(13345):位于android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4292)01-25
01:13:21.059:E / AndroidRuntime(13345)
):位于android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4271)01-25
01:13:21.059:E / AndroidRuntime(13345):位于android.view.ViewRootImpl $
WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4363) 01-25
01:13:21.059:E /
AndroidRuntime(13345):在android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:179)01-25
01:13:21.059:E / AndroidRuntime(13345):在Android。
os.MessageQueue。nativePollOnce(本机方法)01-25 01:13:21.059:E /
AndroidRuntime(13345):在android.os.MessageQueue.next(MessageQueue.java:125)01-25
01:13:21.059:E / AndroidRuntime(13345)
):在android.os.Looper.loop(Looper.java:124)01-25 01:13:21.059:E /
AndroidRuntime(13345):在android.app.ActivityThread.main(ActivityThread.java:5195)01-
25 01:13:21.059:E /
AndroidRuntime(13345):在java.lang.reflect.Method.invokeNative(本地方法)01-25
01:13:21.059:E / AndroidRuntime(13345):在java.lang.reflect
.Method.invoke(Method.java:511)01-25 01:13:21.059:E /
AndroidRuntime(13345):在com.android.internal.os.ZygoteInit $
MethodAndArgsCaller.run(ZygoteInit.java:795)01- 25 01:13:21.059:E /
AndroidRuntime(13345):位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)01-25
01:13:21.059:E / AndroidRuntime(13345):在dalvik.system.NativeStart.main(本机方法)
我想允许用户能够一直拖动到左侧,顶部,右侧和底部。我如何修改以上代码来实现?谢谢!!!
在访问位图之前,将x和y日志记录移至,以查看返回的值。
对于堆栈跟踪,请勿使用值x和y超出位图尺寸的getPixel进行调用。
是否可以以与选项类似的方式处理任一选项?在
我有viewpager和tablayout,内部viewpager有一个创建RecolyerView片段, 在RecyclerVIew roe项目中,我创建了一个水平滚动视图,用于向左/向右移动, 基本上,我只想滑动屏幕的75%左右,然后显示可滑动视图, 我还使用了的,但它会刷行(100%刷行), 但所有这些都不能正常工作,因为当我们在recyclerview项上滑动时,有时触摸到ViewPage
问题内容: 我所看到的和jQuery的。左右滑动的功能/方式如何? 问题答案: 您可以使用jQueryUI中的其他效果来执行此操作: 快速示例:
我正在尝试为我的RecolyerView添加滑动功能。我正在跟随这个链接添加刷卡。https://github.com/nikhilpanju/recyclerviewenhanced/blob/master/recyclerviewenhanced/src/main/java/com/nikhilpanju/recyclerviewenhanced/recyclertouchlistener.j
我有9个j按钮添加到jpanel,面板添加到jscrollpane,它添加到jframe。 http://www.pic1.iran-forum.ir/images/up9/95426323683658592564.jpg 当我更改帧方向时:<代码>applyComponentOrientation(ComponentOrientation.RIGHT\u TO\u LEFT) 面板向右移动,按钮
我搜索了一些滑动示例, 但我仍然找不到从右向左滑动的例子。 请任何一个给样品项目滑动菜单从右到左