标签:always win handler 实现 双击 file long android idg
android:excludeFromRecents="true"
设置为true,则排除在近期任务列表之外。不在近期任务列表中显示
TextUtils.isEmpty(str)
在做一个把EditText放到到ActionBar中作为搜索框的功能时,设置EditText的属性为android:imeOptions="actionSearch"。会遇到一个问题,当在横屏时。EditText的宽度会填充掉屏幕上除了软键盘之外的地方,与需求不符,改为android:imeOptions="actionSearch|flagNoFullscreen"后就OK了。
1、使用image.setColorFilter(Color.GRAY,PorterDuff.Mode.MULTIPLY);能够使图片变暗。然后使用image.clearColorFilter();清除滤镜,恢复到原来的亮度;
2、使用
int brightness = -80;
ColorMatrix matrix = new ColorMatrix();
matrix.set(new float[] { 1, 0, 0, 0, brightness, 0, 1, 0, 0,
brightness, 0, 0, 1, 0, brightness, 0, 0, 0, 1, 0 });
v.setColorFilter(new ColorMatrixColorFilter(matrix));
但这样的方法会使颜色不太正常。图片留有黑边;
看到Android中GestureDetector.java是用以下代码实现手势的单击和双击推断的:
public boolean onTouchEvent(MotionEvent ev) { …… case MotionEvent.ACTION_DOWN: if (mDoubleTapListener != null) { boolean hadTapMessage = mHandler.hasMessages(TAP); if (hadTapMessage) mHandler.removeMessages(TAP); if ((mCurrentDownEvent != null) && (mPreviousUpEvent != null) && hadTapMessage && isConsideredDoubleTap(mCurrentDownEvent, mPreviousUpEvent, ev)) { // This is a second tap mIsDoubleTapping = true; // Give a callback with the first tap of the double-tap handled |= mDoubleTapListener.onDoubleTap(mCurrentDownEvent); // Give a callback with down event of the double-tap handled |= mDoubleTapListener.onDoubleTapEvent(ev); } else { // This is a first tap mHandler.sendEmptyMessageDelayed(TAP, DOUBLE_TAP_TIMEOUT); } } …… } private boolean isConsideredDoubleTap(MotionEvent firstDown, MotionEvent firstUp, MotionEvent secondDown) { if (!mAlwaysInBiggerTapRegion) { return false; } final long deltaTime = secondDown.getEventTime() - firstUp.getEventTime(); if (deltaTime > DOUBLE_TAP_TIMEOUT || deltaTime < DOUBLE_TAP_MIN_TIME) { return false; } int deltaX = (int) firstDown.getX() - (int) secondDown.getX(); int deltaY = (int) firstDown.getY() - (int) secondDown.getY(); return (deltaX * deltaX + deltaY * deltaY < mDoubleTapSlopSquare); } private class GestureHandler extends Handler { GestureHandler() { super(); } GestureHandler(Handler handler) { super(handler.getLooper()); } @Override public void handleMessage(Message msg) { switch (msg.what) { case SHOW_PRESS: mListener.onShowPress(mCurrentDownEvent); break; case LONG_PRESS: dispatchLongPress(); break; case TAP: // If the user‘s finger is still down, do not count it as a tap if (mDoubleTapListener != null) { if (!mStillDown) { mDoubleTapListener.onSingleTapConfirmed(mCurrentDownEvent); } else { mDeferConfirmSingleTap = true; } } break; default: throw new RuntimeException("Unknown message " + msg); //never } }
ImageView的setImageResources方法不仅能够接受drawable的资源,还能够接受color资源:
imageView.setImageResource(R.drawable.XX); imageView.setImageResource(R.color.XX);
该属性是当一个为view获取焦点时,定义viewGroup和其子控件两者之间的关系。
属性的值有三种:PowerManager pm = (PowerManager) mActivity .getSystemService(Context.POWER_SERVICE); WakeLock mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG); mWakeLock.acquire(); //做你想做的时。。
。 mWakeLock.release();
1、当有焦点产生时,软键盘是隐藏还是显示
2、是否降低活动主窗体大小以便腾出空间放软键盘
<TextView android:id="@+id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:text="Test1" android:background="@android:color/holo_blue_light" android:textSize="16dp"/> <TextView android:id="@+id/text2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_toEndOf="@id/text1" android:text="Test2" android:background="@android:color/holo_red_light" android:textSize="16dp"/> </RelativeLayout>
在使用Handler中,假设Activity退出之后我们不再须要发送消息或者运行Runnable,那么就要在onDestory中运行这段代码。否则可能会引起报错。由于可能在onDestory之后才会这些Handler发出的动作。
标签:always win handler 实现 双击 file long android idg
原文地址:http://www.cnblogs.com/liguangsunls/p/7084481.html