View getLayoutParams - 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 getLayoutParams 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: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: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:getLayoutParams, getMeasuredHeight, getMeasuredWidth, setLayoutParams
                view = mAdapter.getView(selectedPosition, null, this);
            } 
 
            if (view != null) {
                // Put in recycler for re-measuring and/or layout 
                mRecycler.put(selectedPosition, view);
            } 
 
            if (view != null) {
                if (view.getLayoutParams() == null) {
                    mBlockLayoutRequests = true;
                    view.setLayoutParams(generateDefaultLayoutParams());
                    mBlockLayoutRequests = false;
                } 
                measureChild(view, widthMeasureSpec, heightMeasureSpec);
 
                preferredHeight = getChildHeight(view) + mSpinnerPadding.top + mSpinnerPadding.bottom;
                preferredWidth = getChildWidth(view) + mSpinnerPadding.left + mSpinnerPadding.right;
 
                needsMeasuring = false;

8
CodeRank
This code example shows how to use the following methods:getHeight, getLayoutParams, setLayoutParams
        public void onDragFloatView(View floatView, Point floatPoint, Point touchPoint) {
            final int first = mDslv.getFirstVisiblePosition();
            final int lvDivHeight = mDslv.getDividerHeight();
 
            if (origHeight == -1) {
                origHeight = floatView.getHeight();
            } 
 
            View div = mDslv.getChildAt(mDivPos - first);
 
            if (touchPoint.x > mDslv.getWidth() / 2) {
                float scale = touchPoint.x - mDslv.getWidth() / 2;
                scale /= (float) (mDslv.getWidth() / 5);
                ViewGroup.LayoutParams lp = floatView.getLayoutParams();
                lp.height = Math.max(origHeight, (int) (scale * origHeight));
                Log.d("mobeta", "setting height "+lp.height);
                floatView.setLayoutParams(lp);
            } 
 
            if (div != null) {

8
CodeRank
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.RIGHT) {
8
CodeRank
This code example shows how to use the following methods:getBottom, getHeight, getLayoutParams, getLeft, getRight
 
        Paint childPaint = this.createPaint(0xffffff00);
        Paint layoutPaint = this.createPaint(0xff00ff00);
        Paint newLinePaint = this.createPaint(0xffff0000);
 
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
 
        if (lp.horizontalSpacing > 0) {
            float x = child.getRight();
            float y = child.getTop() + child.getHeight() / 2.0f;
            canvas.drawLine(x, y, x + lp.horizontalSpacing, y, childPaint);
            canvas.drawLine(x + lp.horizontalSpacing - 4.0f, y - 4.0f, x + lp.horizontalSpacing, y, childPaint);
            canvas.drawLine(x + lp.horizontalSpacing - 4.0f, y + 4.0f, x + lp.horizontalSpacing, y, childPaint);
        } else if (this.horizontalSpacing > 0) {
            float x = child.getRight();
            float y = child.getTop() + child.getHeight() / 2.0f;
            canvas.drawLine(x, y, x + this.horizontalSpacing, y, layoutPaint);
            canvas.drawLine(x + this.horizontalSpacing - 4.0f, y - 4.0f, x + this.horizontalSpacing, y, layoutPaint);
            canvas.drawLine(x + this.horizontalSpacing - 4.0f, y + 4.0f, x + this.horizontalSpacing, y, layoutPaint);
        } 

7
CodeRank
This code example shows how to use the following methods:getLayoutParams, setLayoutParams
   
  SeekBar.OnSeekBarChangeListener v=new SeekBar.OnSeekBarChangeListener() {
    public void onProgressChanged(SeekBar seekBar, 
                                  int progress, 
                                  boolean fromTouch) { 
      ViewGroup.LayoutParams old=thingToResize.getLayoutParams(); 
      ViewGroup.LayoutParams current=new LinearLayout.LayoutParams(old.width, 
                                                                   64+progress); 
       
      thingToResize.setLayoutParams(current); 
    } 
     
    public void onStartTrackingTouch(SeekBar seekBar) { 
      // unused 
    } 
     
    public void onStopTrackingTouch(SeekBar seekBar) { 
      // unused 
    } 
  }; 
7
CodeRank
This code example shows how to use the following methods:getLayoutParams, setLayoutParams
    } 
 
    @Test 
    public void getLayoutParams_shouldReturnTheSameLinearLayoutParamsFromTheSetter() throws Exception { 
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, 2);
        linearLayout.setLayoutParams(params);
 
        assertSame(params, linearLayout.getLayoutParams());
    } 
 
    @Test 
    public void canAnswerOrientation() throws Exception { 
        assertThat(linearLayout.getOrientation()).isEqualTo(LinearLayout.HORIZONTAL);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        assertThat(linearLayout.getOrientation()).isEqualTo(LinearLayout.VERTICAL);
        linearLayout.setOrientation(LinearLayout.HORIZONTAL);
        assertThat(linearLayout.getOrientation()).isEqualTo(LinearLayout.HORIZONTAL);
    } 
 
    @Test 
7
CodeRank
This code example shows how to use the following methods:getLayoutParams, measure, setLayoutParams
        // At this point, we went through the range of children, and they each 
        // completely fit, so return the returnedHeight 
        return returnedHeight;
    } 
    private void measureScrapChild(View child, int position, int widthMeasureSpec) {
        ListView.LayoutParams p = (ListView.LayoutParams) child.getLayoutParams();
        if (p == null) {
            p = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT, 0);
            child.setLayoutParams(p);
        } 
        //XXX p.viewType = mAdapter.getItemViewType(position); 
        //XXX p.forceAdd = true; 
 
        int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec,
                mDropDownList.getPaddingLeft() + mDropDownList.getPaddingRight(), p.width);
        int lpHeight = p.height;
        int childHeightSpec;
        if (lpHeight > 0) {
            childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);

7
CodeRank

Related View getLayoutParams Questions & Answers:

getLayoutParams Method Overview
Get the LayoutParams associated with this view.
See Code Examples for other Android View Methods: