View getWidth - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for View getWidth method.

This code example shows how to use the following methods:getLayoutParams, getWidth, getMax, getProgress, setProgress
            mChronometer.stop();
        } 
 
        // Update the ProgressBar status 
        int remaining = (int) (mDurationBase - now);
        mProgressBar.setProgress(mDuration - remaining);
         
        // Move the Chronometer if gravity is set correctly 
        if (mChronometerFollow) {
            RelativeLayout.LayoutParams params;
             
            // Calculate estimate of ProgressBar leading edge position 
            params = (RelativeLayout.LayoutParams) mProgressBar.getLayoutParams();
            int contentWidth = mProgressBar.getWidth() - (params.leftMargin + params.rightMargin);
            int leadingEdge = ((contentWidth * mProgressBar.getProgress()) /
                    mProgressBar.getMax()) + params.leftMargin;
             
            // Calculate any adjustment based on gravity 
            int adjustLeft = 0;
            int textWidth = mChronometer.getWidth();
            if (mChronometerGravity == Gravity.END) {
9
CodeRank
This code example shows how to use the following methods:getContext, getHeight, getLocationOnScreen, getWidth, getWindowVisibleDisplayFrame
            return false; 
        } 
 
        final int[] screenPos = new int[2]; // origin is device display
        final Rect displayFrame = new Rect(); // includes decorations (e.g. status bar)
        view.getLocationOnScreen(screenPos);
        view.getWindowVisibleDisplayFrame(displayFrame);
 
        final Context context = view.getContext();
        final int viewWidth = view.getWidth();
        final int viewHeight = view.getHeight();
        final int viewCenterX = screenPos[0] + viewWidth / 2;
        final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
        final int estimatedToastHeight = (int) (ESTIMATED_TOAST_HEIGHT_DIPS
                * context.getResources().getDisplayMetrics().density);
 
        Toast cheatSheet = Toast.makeText(context, text, Toast.LENGTH_SHORT);
        boolean showBelow = screenPos[1] < estimatedToastHeight;
        if (showBelow) {
            // Show below 
9
CodeRank
This code example shows how to use the following methods:getHeight, getLeft, getParent, getTop, getWidth
            computeRect(mBefore, view);
        } 
    } 
    private void invalidateAfterUpdate() { 
        View view = mView.get();
        if (view == null || view.getParent() == null) {
            return; 
        } 
 
        final RectF after = mAfter;
        computeRect(after, view);
        after.union(mBefore);
 
        ((View)view.getParent()).invalidate(
                (int) Math.floor(after.left),
                (int) Math.floor(after.top),
                (int) Math.ceil(after.right),
                (int) Math.ceil(after.bottom));
    } 
 

8
CodeRank
This code example shows how to use the following methods:getHeight, getLeft, getWidth, layout
        public void onClick(View v) {
            move(this.v);
        } 
 
        public void move(View v) {
            v.layout(v.getLeft() + dx, 0, v.getLeft() + dx + v.getWidth(), v.getHeight());
            ViewUtils.printView("menu", v);
        } 
    } 
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.animation_stacked_frames);
 
        mFrameLayout = (FrameLayout) this.findViewById(R.id.flipper);
        menu = mFrameLayout.findViewById(R.id.menu);
        app = mFrameLayout.findViewById(R.id.app);
 
        ViewUtils.printView("menu", menu);
8
CodeRank
This code example shows how to use the following methods:getHeight, getLocationOnScreen, getWidth
 
        // Replaces the background of the popup with a cleared background 
        setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
 
        final int[] loc = mLocation;
        anchor.getLocationOnScreen(loc);
        mRect.set(loc[0], loc[1], loc[0] + anchor.getWidth(), loc[1] + anchor.getHeight());
 
        if (mIsDirty) {
            clearQuickActions(); 
            populateQuickActions(mQuickActions);
        } 
 
        onMeasureAndLayout(mRect, contentView);
 
        if ((mPrivateFlags & MEASURE_AND_LAYOUT_DONE) != MEASURE_AND_LAYOUT_DONE) {
            throw new IllegalStateException("onMeasureAndLayout() did not set the widget specification by calling"
                    + " setWidgetSpecs()"); 
        } 
 
8
CodeRank
This code example shows how to use the following methods:getHeight, getLeft, getParent, getTop, getWidth
                (int) FloatMath.ceil(after.bottom));
    } 
 
    private void computeRect(final RectF r, View view) {
        // compute current rectangle according to matrix transformation 
        final float w = view.getWidth();
        final float h = view.getHeight();
 
        // use a rectangle at 0,0 to make sure we don't run into issues with scaling 
        r.set(0, 0, w, h);
 
        final Matrix m = mTempMatrix;
        m.reset();
        transformMatrix(m, view);
        mTempMatrix.mapRect(r);
 
        r.offset(view.getLeft(), view.getTop());
 
        // Straighten coords if rotations flipped them 
        if (r.right < r.left) {

8
CodeRank
This code example shows how to use the following methods:getLayoutParams, getWidth
	 */ 
	@Override 
	public int getWidth() { 
		ImageView imageView = imageViewRef.get();
		if (imageView != null) {
			final ViewGroup.LayoutParams params = imageView.getLayoutParams();
			int width = 0;
			if (checkActualViewSize && params != null && params.width != ViewGroup.LayoutParams.WRAP_CONTENT) {
				width = imageView.getWidth(); // Get actual image width
			} 
			if (width <= 0 && params != null) width = params.width; // Get layout width parameter
			if (width <= 0) width = getImageViewFieldValue(imageView, "mMaxWidth"); // Check maxWidth parameter
			return width;
		} 
		return 0; 
	} 
 
	/** 
	 * {@inheritDoc} 
	 * <p/> 
8
CodeRank
This code example shows how to use the following methods:getContentDescription, getHeight, getId, getLocationOnScreen, getWidth
 
	@SuppressWarnings({ "rawtypes", "unchecked" }) 
	public static Object extractDataFromView(View v) {		
		 
		Map data = new HashMap();
		data.put("class", v.getClass().getName());		
		data.put("description", v.toString());
		CharSequence description = v.getContentDescription();
		data.put("contentDescription", description != null ? description.toString() : null);
		data.put("enabled", v.isEnabled());
		String id = null;
		try { 
			id = InstrumentationBackend.solo.getCurrentActivity()
					.getResources().getResourceEntryName(v.getId());
		} catch (Resources.NotFoundException e) {
			System.out.println("Resource not found for " + v.getId()
					+ ". Moving on."); 
		} 
		data.put("id", id);
 

8
CodeRank
This code example shows how to use the following methods:getHeight, getLeft, getParent, getTop, getWidth
            if (view != null)
                computeRect(mBefore, view);
        } 
 
        private void computeRect(final RectF r, View view) {
            final float w = view.getWidth();
            final float h = view.getHeight();
 
            r.set(0, 0, w, h);
 
            final Matrix m = mTempMatrix;
            m.reset();
            transformMatrix(m, view);
            mTempMatrix.mapRect(r);
 
            r.offset(view.getLeft(), view.getTop());
        } 
 
        private void transformMatrix(Matrix m, View view) {
            m.postTranslate(mTranslationX, mTranslationY);

8
CodeRank
This code example shows how to use the following methods:draw, getHeight, getWidth
		this.view = activity.findViewById(id);
	} 
	 
	/** Take a snapshot of the view. */ 
	public Bitmap snap() {
		Bitmap bitmap = Bitmap.createBitmap(this.view.getWidth(),
				this.view.getHeight(), Config.ARGB_8888);
		Canvas canvas = new Canvas(bitmap);
		view.draw(canvas);
		return bitmap;
	} 
} 
8
CodeRank

Related View getWidth Questions & Answers:

getWidth Method Overview
Return the width of the your view.
See Code Examples for other Android View Methods: