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


Java View.getWidth方法代码示例

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


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

示例1: onViewReleased

import android.view.View; //导入方法依赖的package包/类
@Override
public void onViewReleased(View releasedChild, float xvel, float yvel) {
    final int childWidth = releasedChild.getWidth();
    final int childHeight = releasedChild.getHeight();

    int left = 0, top = 0;
    if ((mTrackingEdge & EDGE_LEFT) != 0) {
        left = xvel > 0 || xvel == 0 && mScrollPercent > mScrollThreshold ? childWidth
                + mShadowLeft.getIntrinsicWidth() + OVERSCROLL_DISTANCE : 0;
    } else if ((mTrackingEdge & EDGE_RIGHT) != 0) {
        left = xvel < 0 || xvel == 0 && mScrollPercent > mScrollThreshold ? -(childWidth
                + mShadowLeft.getIntrinsicWidth() + OVERSCROLL_DISTANCE) : 0;
    } else if ((mTrackingEdge & EDGE_BOTTOM) != 0) {
        top = yvel < 0 || yvel == 0 && mScrollPercent > mScrollThreshold ? -(childHeight
                + mShadowBottom.getIntrinsicHeight() + OVERSCROLL_DISTANCE) : 0;
    }

    mDragHelper.settleCapturedViewAt(left, top);
    invalidate();
}
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:21,代码来源:SwipeBackLayout.java

示例2: onViewReleased

import android.view.View; //导入方法依赖的package包/类
@Override
public void onViewReleased(View releasedChild, float xvel, float yvel) {
  // Offset is how open the drawer is, therefore left/right values
  // are reversed from one another.
  final float offset = getDrawerViewOffset(releasedChild);
  final int childWidth = releasedChild.getWidth();

  int left;
  if (checkDrawerViewAbsoluteGravity(releasedChild, Gravity.LEFT)) {
    left = xvel > 0 || xvel == 0 && offset > 0.5f ? 0 : -childWidth;
  } else {
    final int width = getWidth();
    left = xvel < 0 || xvel == 0 && offset > 0.5f ? width - childWidth : width;
  }

  mDragger.settleCapturedViewAt(left, releasedChild.getTop());
  invalidate();
}
 
开发者ID:rogues-dev,项目名称:superglue,代码行数:19,代码来源:DebugDrawerLayout.java

示例3: updateIndicatorPosition

import android.view.View; //导入方法依赖的package包/类
private void updateIndicatorPosition() {
    int right;
    int left;
    View selectedTitle = getChildAt(this.mSelectedPosition);
    if (selectedTitle == null || selectedTitle.getWidth() <= 0) {
        right = -1;
        left = -1;
    } else {
        left = selectedTitle.getLeft();
        right = selectedTitle.getRight();
        if (this.mSelectionOffset > 0.0f && this.mSelectedPosition < getChildCount() - 1) {
            View nextTitle = getChildAt(this.mSelectedPosition + 1);
            left = (int) ((this.mSelectionOffset * ((float) nextTitle.getLeft())) + ((1.0f - this.mSelectionOffset) * ((float) left)));
            right = (int) ((this.mSelectionOffset * ((float) nextTitle.getRight())) + ((1.0f - this.mSelectionOffset) * ((float) right)));
        }
    }
    setIndicatorPosition(left, right);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:TabLayout.java

示例4: drawHorizontal

import android.view.View; //导入方法依赖的package包/类
public void drawHorizontal(Canvas c, RecyclerView parent) {

        final int childCount = parent.getChildCount();

        // 在每一个子控件的底部画线
        for (int i = 0; i < childCount; i++) {
            final View child = parent.getChildAt(i);

            final int left = child.getLeft() + child.getPaddingLeft();
            final int right = child.getWidth() + child.getLeft() - child.getPaddingRight();
            final int top = child.getBottom() - mDivider.getIntrinsicHeight() - child.getPaddingBottom();
            final int bottom = top + mDivider.getIntrinsicHeight();
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(c);
        }
    }
 
开发者ID:popo1379,项目名称:popomusic,代码行数:17,代码来源:MyItemDecoration.java

示例5: onTouch

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onTouch(final View v, final MotionEvent event) {
    switch (event.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            onTouchDown(v);
            return true;
        case MotionEvent.ACTION_MOVE:
            final float x = event.getX();
            final float y = event.getY();
            if (x < 0.0f || v.getWidth() < x || y < 0.0f || v.getHeight() < y) {
                // Stop generating key events once the finger moves away from the view area.
                onTouchCanceled(v);
            }
            return true;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            onTouchUp(v);
            return true;
    }
    return false;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:22,代码来源:EmojiPalettesView.java

示例6: MjpegViewThread

import android.view.View; //导入方法依赖的package包/类
public MjpegViewThread(SurfaceHolder surfaceHolder, View view){
    mSurfaceHolder = surfaceHolder;
    mRun = false;
    mCallback = null;
    dispWidth = view.getWidth();
    dispHeight = view.getHeight();
    prevdispWidth = dispWidth;
    prevdispHeight = dispHeight;
    destRect = new Rect(0,0,dispWidth,dispHeight);
    destSrc = null;
    displayMode = 1; // Default : SIZE_FIT_MODE
    prevdisplayMode = 1;

    bgColor = new Paint();
    bgColor.setStyle(Paint.Style.FILL);
    bgColor.setARGB(255, 0, 0, 0);
}
 
开发者ID:dydwo92,项目名称:Android-Simple-MjpegViewer,代码行数:18,代码来源:MjpegViewThread.java

示例7: transformPage

import android.view.View; //导入方法依赖的package包/类
@SuppressLint("NewApi")
public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();

    Log.e("TAG", view + " , " + position + "");

    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);

    } else if (position <= 1) //a页滑动至b页 ; a页从 0.0 -1 ;b页从1 ~ 0.0
    { // [-1,1]
        // Modify the default slide transition to shrink the page as well
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float vertMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;
        if (position < 0) {
            view.setTranslationX(horzMargin - vertMargin / 2);
        } else {
            view.setTranslationX(-horzMargin + vertMargin / 2);
        }

        // Scale the page down (between MIN_SCALE and 1)
        view.setScaleX(scaleFactor);
        view.setScaleY(scaleFactor);

        // Fade the page relative to its size.
        view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE)
                / (1 - MIN_SCALE) * (1 - MIN_ALPHA));

    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:37,代码来源:ZoomOutPageTransformer.java

示例8: animateToTab

import android.view.View; //导入方法依赖的package包/类
private void animateToTab(final int position) {
    final View tabView = mTabLayout.getChildAt(position);
    if (mTabSelector != null) {
        removeCallbacks(mTabSelector);
    }
    mTabSelector = new Runnable() {
        public void run() {
            final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2;
            smoothScrollTo(scrollPos, 0);
            mTabSelector = null;
        }
    };
    post(mTabSelector);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:TabPageIndicator.java

示例9: onTransform

import android.view.View; //导入方法依赖的package包/类
@Override
protected void onTransform(View view, float position) {
	final float width = view.getWidth();
	final float rotation = ROT_MOD * position;

	view.setPivotX(width * 0.5f);
	view.setPivotY(0f);
	view.setTranslationX(0f);
	view.setRotation(rotation);
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:11,代码来源:RotateUpTransformer.java

示例10: transformPage

import android.view.View; //导入方法依赖的package包/类
public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();

    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);

    } else if (position <= 1) { // [-1,1]
        // Modify the default slide transition to shrink the page as well
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float vertMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;
        if (position < 0) {
            view.setTranslationX(horzMargin - vertMargin / 2);
        } else {
            view.setTranslationX(-horzMargin + vertMargin / 2);
        }

        // Scale the page down (between MIN_SCALE and 1)
        view.setScaleX(scaleFactor);
        view.setScaleY(scaleFactor);

        // Fade the page relative to its size.
        view.setAlpha(MIN_ALPHA +
                (scaleFactor - MIN_SCALE) /
                (1 - MIN_SCALE) * (1 - MIN_ALPHA));

    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}
 
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:34,代码来源:ZoomOutPageTransformer.java

示例11: isTouchPointInView

import android.view.View; //导入方法依赖的package包/类
public static boolean isTouchPointInView(@NonNull View view, float x, float y) {
    final int[] coordinates = new int[3];
    view.getLocationInWindow(coordinates);
    int left = coordinates[0];
    int top = coordinates[1];
    return x >= left && x <= left + view.getWidth() &&
            y >= top && y <= top + view.getHeight();
}
 
开发者ID:ujjwalagrawal17,项目名称:CodeCompilerApp,代码行数:9,代码来源:ViewUtils.java

示例12: onProfileClick

import android.view.View; //导入方法依赖的package包/类
@Override
public void onProfileClick(View v) {
    int[] startingLocation = new int[2];
    v.getLocationOnScreen(startingLocation);
    startingLocation[0] += v.getWidth() / 2;
    // ProfileActivity.startUserProfileFromLocation(startingLocation, this);
    overridePendingTransition(0, 0);
}
 
开发者ID:NarendraSickarwar,项目名称:FirebasePost,代码行数:9,代码来源:MainActivity.java

示例13: captureEndValues

import android.view.View; //导入方法依赖的package包/类
@Override
public void captureEndValues(TransitionValues transitionValues) {
    super.captureEndValues(transitionValues);
    final View view = transitionValues.view;
    if (view.getWidth() <= 0 || view.getHeight() <= 0) {
        return;
    }
    transitionValues.values.put(PROPERTY_COLOR, endColor);//ContextCompat.getColor(view.getContext(), R.color.dialog_background_color)
    transitionValues.values.put(PROPERTY_CORNER_RADIUS, endCornerRadius);
}
 
开发者ID:li-yu,项目名称:Huahui-Android,代码行数:11,代码来源:MorphTransition.java

示例14: setBackground

import android.view.View; //导入方法依赖的package包/类
public static void setBackground(View v, Bitmap bm) {

        if (bm == null) {
            v.setBackgroundResource(0);
            return;
        }

        int vwidth = v.getWidth()/4;
        int vheight = v.getHeight()/4;
        int bwidth = bm.getWidth();
        int bheight = bm.getHeight();
        float scalex = (float) vwidth / bwidth;
        float scaley = (float) vheight / bheight;
        float scale = Math.max(scalex, scaley) * 1.3f;

        Bitmap.Config config = Bitmap.Config.ARGB_8888;
        Bitmap bg = Bitmap.createBitmap(vwidth, vheight, config);
        Canvas c = new Canvas(bg);
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setFilterBitmap(true);
        ColorMatrix greymatrix = new ColorMatrix();
        greymatrix.setSaturation(0);
        ColorMatrix darkmatrix = new ColorMatrix();
        darkmatrix.setScale(1f, 1f, 1f, .1f);
        greymatrix.postConcat(darkmatrix);
        ColorFilter filter = new ColorMatrixColorFilter(greymatrix);
        paint.setColorFilter(filter);
        Matrix matrix = new Matrix();
        matrix.setTranslate(-bwidth/2, -bheight/2); // move bitmap center to origin
        matrix.postRotate(10);
        matrix.postScale(scale, scale);
        matrix.postTranslate(vwidth/2, vheight/2);  // Move bitmap center to view center
        c.drawBitmap(bm, matrix, paint);
        v.setBackgroundDrawable(new BitmapDrawable(bg));
    }
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:37,代码来源:Utils.java

示例15: isTouchInView

import android.view.View; //导入方法依赖的package包/类
public static boolean isTouchInView(MotionEvent ev, View v) {
    int[] vLoc = new int[2];
    v.getLocationOnScreen(vLoc);
    float motionX = ev.getRawX();
    float motionY = ev.getRawY();
    return motionX >= vLoc[0] && motionX <= (vLoc[0] + v.getWidth()) && motionY >= vLoc[1] && motionY <= (vLoc[1] + v.getHeight());
}
 
开发者ID:jeasinlee,项目名称:AndroidBasicLibs,代码行数:8,代码来源:ViewUtils.java


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