View getHeight - 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 getHeight method.

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:getHeight, getLayoutParams
	 */ 
	@Override 
	public int getHeight() { 
		ImageView imageView = imageViewRef.get();
		if (imageView != null) {
			final ViewGroup.LayoutParams params = imageView.getLayoutParams();
			int height = 0;
			if (checkActualViewSize && params != null && params.height != ViewGroup.LayoutParams.WRAP_CONTENT) {
				height = imageView.getHeight(); // Get actual image height
			} 
			if (height <= 0 && params != null) height = params.height; // Get layout height parameter
			if (height <= 0) height = getImageViewFieldValue(imageView, "mMaxHeight"); // Check maxHeight parameter
			return height;
		} 
		return 0; 
	} 
 
	@Override 
	public ViewScaleType getScaleType() { 
		ImageView imageView = imageViewRef.get();
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, getLayoutParams, getVisibility, setVisibility
 
    public CollapseAnimation(View view, int duration) {
 
        setDuration(duration);
        mAnimatedView = view;
        mViewLayoutParams = (LinearLayout.LayoutParams) view.getLayoutParams();
 
        // decide to show or hide the view 
        mIsVisibleAfter = (view.getVisibility() == View.VISIBLE);
 
        mMarginStart = mViewLayoutParams.bottomMargin;
        mMarginEnd = (mMarginStart == 0 ? (0 - view.getHeight()) : 0);
 
        view.setVisibility(View.VISIBLE);
    } 
 
    @Override 
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        super.applyTransformation(interpolatedTime, t);
 
8
CodeRank
This code example shows how to use the following methods:getHeight, setGravity, setText, setTextColor, setTextSize
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

Related View getHeight Questions & Answers:

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