当前位置: 首页>>代码示例>>Java>>正文


Java ViewConfiguration类代码示例

本文整理汇总了Java中android.view.ViewConfiguration的典型用法代码示例。如果您正苦于以下问题:Java ViewConfiguration类的具体用法?Java ViewConfiguration怎么用?Java ViewConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ViewConfiguration类属于android.view包,在下文中一共展示了ViewConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.view.ViewConfiguration; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_fold);

    mImageView = (ImageView)findViewById(R.id.image_view);
    mImageView.setPadding(ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING,
            ANTIALIAS_PADDING);
    mImageView.setScaleType(ImageView.ScaleType.FIT_XY);
    mImageView.setImageDrawable(getResources().getDrawable(R.drawable.image));

    mTextureView = new TextureView(this);
    mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);

    mAnchorSeekBar = (SeekBar)findViewById(R.id.anchor_seek_bar);
    mFoldLayout = (FoldingLayout)findViewById(R.id.fold_view);
    mFoldLayout.setBackgroundColor(Color.BLACK);
    mFoldLayout.setFoldListener(mOnFoldListener);

    mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();

    mAnchorSeekBar.setOnSeekBarChangeListener(mSeekBarChangeListener);

    mScrollGestureDetector = new GestureDetector(this, new ScrollGestureDetector());
    mItemSelectedListener = new ItemSelectedListener();

    mDefaultPaint = new Paint();
    mSepiaPaint = new Paint();

    ColorMatrix m1 = new ColorMatrix();
    ColorMatrix m2 = new ColorMatrix();
    m1.setSaturation(0);
    m2.setScale(1f, .95f, .82f, 1.0f);
    m1.setConcat(m2, m1);
    mSepiaPaint.setColorFilter(new ColorMatrixColorFilter(m1));
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:38,代码来源:FoldingLayoutActivity.java

示例2: run

import android.view.ViewConfiguration; //导入依赖的package包/类
public void run() {
    if (isPressed()) {
        if (mCode != 0) {
            if (mCode == KeyEvent.KEYCODE_DPAD_LEFT || mCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
                sendEvent(KeyEvent.ACTION_UP, KeyEvent.FLAG_SOFT_KEYBOARD |
                        KeyEvent.FLAG_KEEP_TOUCH_MODE, System.currentTimeMillis(), false);
                sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_SOFT_KEYBOARD |
                        KeyEvent.FLAG_KEEP_TOUCH_MODE, System.currentTimeMillis(), false);
                removeCallbacks(mCheckLongPress);
                postDelayed(mCheckLongPress, ViewConfiguration.getKeyRepeatDelay());
            } else {
                sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS);
                sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
            }
        } else {
            mLongPressConsumed = performLongClick();
        }
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:20,代码来源:KeyButtonView.java

示例3: init

import android.view.ViewConfiguration; //导入依赖的package包/类
@SuppressLint({"NewApi"})
private void init(Context context, AttributeSet attrs) {
    setGravity(17);
    this.mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    DisplayMetrics localDisplayMetrics = new DisplayMetrics();
    ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
    this.mScreenHeight = localDisplayMetrics.heightPixels;
    this.mScreenWidth = localDisplayMetrics.widthPixels;
    this.mRootView = createRootView(context, attrs);
    if (attrs != null) {
        LayoutInflater mLayoutInflater = LayoutInflater.from(getContext());
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.PullToZoomView);
        int zoomViewResId = a.getResourceId(2, 0);
        if (zoomViewResId > 0) {
            this.mZoomView = mLayoutInflater.inflate(zoomViewResId, null, false);
        }
        int headerViewResId = a.getResourceId(0, 0);
        if (headerViewResId > 0) {
            this.mHeaderView = mLayoutInflater.inflate(headerViewResId, null, false);
        }
        this.isParallax = a.getBoolean(1, true);
        handleStyledAttributes(a);
        a.recycle();
    }
    addView(this.mRootView, -1, -1);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:27,代码来源:PullToZoomBase.java

示例4: ViewDragHelper

import android.view.ViewConfiguration; //导入依赖的package包/类
/**
 * Apps should use ViewDragHelper.create() to get a new instance.
 * This will allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context   Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:29,代码来源:ViewDragHelper.java

示例5: onCreate

import android.view.ViewConfiguration; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    actionBar = getSupportActionBar();

    // Hack. Forcing overflow button on actionbar on devices with hardware menu button
    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
        // Ignore
    }
}
 
开发者ID:mobilemaster128,项目名称:quickblox-android,代码行数:19,代码来源:CoreBaseActivity.java

示例6: GooglePhotosGestureDetector

import android.view.ViewConfiguration; //导入依赖的package包/类
public GooglePhotosGestureDetector(@Nullable Context context, @NonNull GooglePhotosGestureListener listener) {
    this.gestureListener = listener;
    gestureHandler = new GestureHandler();
    if (context == null) {
        MIN_FLING_VELOCITY = ViewConfiguration.getMinimumFlingVelocity();
        MAX_FLING_VELOCITY = ViewConfiguration.getMaximumFlingVelocity();
        DOUBLE_TAP_SLOP = 100;
        SCALE_SPAN_SLOP = 16;
    } else {
        ViewConfiguration config = ViewConfiguration.get(context);
        MIN_FLING_VELOCITY = config.getScaledMinimumFlingVelocity();
        MAX_FLING_VELOCITY = config.getScaledMaximumFlingVelocity();
        DOUBLE_TAP_SLOP = config.getScaledDoubleTapSlop();
        SCALE_SPAN_SLOP = config.getScaledTouchSlop() * 2;
    }
}
 
开发者ID:xyzxqs,项目名称:XphotoView,代码行数:17,代码来源:GooglePhotosGestureDetector.java

示例7: onTouch

import android.view.ViewConfiguration; //导入依赖的package包/类
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
	switch (motionEvent.getAction()) {
		case ACTION_DOWN:
			view.postDelayed(repeater,
					ViewConfiguration.getKeyRepeatTimeout());
			performHapticFeedback(KEYBOARD_TAP);
			return false;
		case ACTION_CANCEL:
		case ACTION_UP:
			view.removeCallbacks(repeater);
			return false;
		default:
			return false;
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:17,代码来源:RepeatableImageKey.java

示例8: setScrollingTouchSlop

import android.view.ViewConfiguration; //导入依赖的package包/类
/**
 * Configure the scrolling touch slop for a specific use case.
 *
 * Set up the RecyclerView's scrolling motion threshold based on common usages.
 * Valid arguments are {@link #TOUCH_SLOP_DEFAULT} and {@link #TOUCH_SLOP_PAGING}.
 *
 * @param slopConstant One of the <code>TOUCH_SLOP_</code> constants representing
 *                     the intended usage of this RecyclerView
 */
public void setScrollingTouchSlop(int slopConstant) {
    final ViewConfiguration vc = ViewConfiguration.get(getContext());
    switch (slopConstant) {
        default:
            Log.w(TAG, "setScrollingTouchSlop(): bad argument constant "
                    + slopConstant + "; using default value");
            // fall-through
        case TOUCH_SLOP_DEFAULT:
            mTouchSlop = vc.getScaledTouchSlop();
            break;

        case TOUCH_SLOP_PAGING:
            mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(vc);
            break;
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:26,代码来源:RecyclerView.java

示例9: hasNavBar

import android.view.ViewConfiguration; //导入依赖的package包/类
@TargetApi(14)
private boolean hasNavBar(Context context) {
    Resources res = context.getResources();
    int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool", "android");
    if (resourceId != 0) {
        boolean hasNav = res.getBoolean(resourceId);
        // check override flag (see static block)
        if ("1".equals(sNavBarOverride)) {
            hasNav = false;
        } else if ("0".equals(sNavBarOverride)) {
            hasNav = true;
        }
        return hasNav;
    } else { // fallback
        return !ViewConfiguration.get(context).hasPermanentMenuKey();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:SystemBarTintManager.java

示例10: ViewDragHelper

import android.view.ViewConfiguration; //导入依赖的package包/类
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    } else if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    } else {
        this.mParentView = forParent;
        this.mCallback = cb;
        ViewConfiguration vc = ViewConfiguration.get(context);
        this.mEdgeSize = (int) ((20.0f * context.getResources().getDisplayMetrics().density) + 0.5f);
        this.mTouchSlop = vc.getScaledTouchSlop();
        this.mMaxVelocity = (float) vc.getScaledMaximumFlingVelocity();
        this.mMinVelocity = (float) vc.getScaledMinimumFlingVelocity();
        this.mScroller = ScrollerCompat.create(context, sInterpolator);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:ViewDragHelper.java

示例11: SlidingLocaleDrawable

import android.view.ViewConfiguration; //导入依赖的package包/类
@SuppressLint("ResourceAsColor")
public SlidingLocaleDrawable(Drawable background, int width, int height) {
          mBackground = background;
          setDefaultBounds(mBackground);
          mWidth = width;
          mHeight = height;
          mTextPaint = new TextPaint();
          mTextPaint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Medium, 18));
          
          mTextPaint.setColor(R.color.latinkeyboard_transparent);
          mTextPaint.setTextAlign(Align.CENTER);
          mTextPaint.setAlpha(OPACITY_FULLY_OPAQUE);
          mTextPaint.setAntiAlias(true);
          mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2;
          mLeftDrawable =
                  mRes.getDrawable(R.drawable.sym_keyboard_feedback_language_arrows_left);
          mRightDrawable =
                  mRes.getDrawable(R.drawable.sym_keyboard_feedback_language_arrows_right);
          mThreshold = ViewConfiguration.get(mContext).getScaledTouchSlop();
      }
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:21,代码来源:LatinKeyboard.java

示例12: StackLayout

import android.view.ViewConfiguration; //导入依赖的package包/类
/**
 * @param context     The current Android's context.
 * @param updateHost  The {@link LayoutUpdateHost} view for this layout.
 * @param renderHost  The {@link LayoutRenderHost} view for this layout.
 * @param eventFilter The {@link EventFilter} that is needed for this view.
 */
public StackLayout(Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost,
        EventFilter eventFilter) {
    super(context, updateHost, renderHost, eventFilter);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mMinDirectionThreshold = configuration.getScaledTouchSlop();
    mMinShortPressThresholdSqr =
            configuration.getScaledPagingTouchSlop() * configuration.getScaledPagingTouchSlop();

    mMinMaxInnerMargin = (int) (MIN_INNER_MARGIN_PERCENT_DP + 0.5);
    mFlingSpeed = FLING_SPEED_DP;
    mStacks = new Stack[2];
    mStacks[0] = new Stack(context, this);
    mStacks[1] = new Stack(context, this);
    mStackRects = new RectF[2];
    mStackRects[0] = new RectF();
    mStackRects[1] = new RectF();

    mViewContainer = new FrameLayout(getContext());
    mSceneLayer = new TabListSceneLayer();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:28,代码来源:StackLayout.java

示例13: DraggableSquareView

import android.view.ViewConfiguration; //导入依赖的package包/类
public DraggableSquareView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mDragHelper = ViewDragHelper
            .create(this, 10f, new DragHelperCallback());
    moveDetector = new GestureDetectorCompat(context,
            new MoveDetector());
    moveDetector.setIsLongpressEnabled(false); // 不能处理长按事件,否则违背最初设计的初衷
    spaceInterval = (int) getResources().getDimension(R.dimen.drag_square_interval); // 小方块之间的间隔

    // 滑动的距离阈值由系统提供
    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();

    anchorHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (draggingView != null) {
                // 开始移动重心的动画
                draggingView.startAnchorAnimation();
            }
        }
    };
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:24,代码来源:DraggableSquareView.java

示例14: isFlingingToDelete

import android.view.ViewConfiguration; //导入依赖的package包/类
/**
 * Determines whether the user flung the current item to delete it.
 *
 * @return the vector at which the item was flung, or null if no fling was detected.
 */
private PointF isFlingingToDelete(DragSource source) {
    if (mFlingToDeleteDropTarget == null) return null;
    if (!source.supportsFlingToDelete()) return null;

    ViewConfiguration config = ViewConfiguration.get(mLauncher);
    mVelocityTracker.computeCurrentVelocity(1000, config.getScaledMaximumFlingVelocity());
    PointF vel = new PointF(mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity());
    float theta = MAX_FLING_DEGREES + 1;
    if (mVelocityTracker.getYVelocity() < mFlingToDeleteThresholdVelocity) {
        // Do a quick dot product test to ensure that we are flinging upwards
        PointF upVec = new PointF(0f, -1f);
        theta = getAngleBetweenVectors(vel, upVec);
    } else if (mLauncher.getDeviceProfile().isVerticalBarLayout() &&
            mVelocityTracker.getXVelocity() < mFlingToDeleteThresholdVelocity) {
        // Remove icon is on left side instead of top, so check if we are flinging to the left.
        PointF leftVec = new PointF(-1f, 0f);
        theta = getAngleBetweenVectors(vel, leftVec);
    }
    if (theta <= Math.toRadians(MAX_FLING_DEGREES)) {
        return vel;
    }
    return null;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:29,代码来源:DragController.java

示例15: ViewDragHelper

import android.view.ViewConfiguration; //导入依赖的package包/类
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    } else if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    } else {
        this.mParentView = forParent;
        this.mCallback = cb;
        ViewConfiguration vc = ViewConfiguration.get(context);
        this.mEdgeSize = (int) ((TitleBar.BACKBTN_LEFT_MARGIN * context.getResources().getDisplayMetrics().density) + 0.5f);
        this.mTouchSlop = vc.getScaledTouchSlop();
        this.mMaxVelocity = (float) vc.getScaledMaximumFlingVelocity();
        this.mMinVelocity = (float) vc.getScaledMinimumFlingVelocity();
        this.mScroller = ScrollerCompat.create(context, sInterpolator);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:17,代码来源:ViewDragHelper.java


注:本文中的android.view.ViewConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。