added in [version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)   
belongs to Maven artifact com.android.support:percent:28.0.0-alpha1   
Deprecated since version 26.1.0 Summary: [Nested Classes](https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#nestedclasses) \| [Ctors](https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#pubctors) \| [Methods](https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#inhmethods) \| [\[Expand All\]](https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#)

# PercentLayoutHelper


`
public


class
PercentLayoutHelper
`


`

extends Object


`

`


`

|---|---|
| java.lang.Object ||
| ↳ | android.support.percent.PercentLayoutHelper |

<br />

*** ** * ** ***


**This class was deprecated
in API level 26.1.0.**   

consider using ConstraintLayout and associated layouts instead. The following shows
how to replicate the functionality of percentage layouts with a ConstraintLayout. The Guidelines
are used to define each percentage break point, and then a Button view is stretched to fill
the gap:

````
 <android.support.constraint.ConstraintLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:app="http://schemas.android.com/apk/res-auto"
         android:layout_width="match_parent"
         android:layout_height="match_parent"&gt

     <android.support.constraint.Guideline
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:id="@+id/left_guideline"
         app:layout_constraintGuide_percent=".15"
         android:orientation="vertical"/&gt

     <android.support.constraint.Guideline
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:id="@+id/right_guideline"
         app:layout_constraintGuide_percent=".85"
         android:orientation="vertical"/&gt

     <android.support.constraint.Guideline
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:id="@+id/top_guideline"
         app:layout_constraintGuide_percent=".15"
         android:orientation="horizontal"/&gt

     <android.support.constraint.Guideline
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:id="@+id/bottom_guideline"
         app:layout_constraintGuide_percent=".85"
         android:orientation="horizontal"/&gt

     <Button
         android:text="Button"
         android:layout_width="0dp"
         android:layout_height="0dp"
         android:id="@+id/button"
         app:layout_constraintLeft_toLeftOf="@+id/left_guideline"
         app:layout_constraintRight_toRightOf="@+id/right_guideline"
         app:layout_constraintTop_toTopOf="@+id/top_guideline"
         app:layout_constraintBottom_toBottomOf="@+id/bottom_guideline" /&gt

 </android.support.constraint.ConstraintLayout&gt

  


  Helper for layouts that want to support percentage based dimensions.

 This class collects utility methods that are involved in extracting percentage based dimension
 attributes and applying them to ViewGroup's children. If you would like to implement a layout
 that supports percentage based dimensions, you need to take several steps:

 
 
-  You need a `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html` subclass in your ViewGroup that implements
   `https://developer.android.com/reference/android/support/percent/PercentLayoutHelper.PercentLayoutParams`.
   

-  In your `LayoutParams(Context c, AttributeSet attrs)` constructor create an instance
   of `https://developer.android.com/reference/android/support/percent/PercentLayoutHelper.PercentLayoutInfo` by calling
   `https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#getPercentLayoutInfo(android.content.Context, android.util.AttributeSet)`. Return this
   object from `public PercentLayoutHelper.PercentLayoutInfo getPercentLayoutInfo()`
   method that you implemented for `https://developer.android.com/reference/android/support/percent/PercentLayoutHelper.PercentLayoutParams` interface.
   

-  Override
   `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html#setBaseAttributes(android.content.res.TypedArray, int, int)`
   with a single line implementation `PercentLayoutHelper.fetchWidthAndHeight(this, a,
   widthAttr, heightAttr);`
   

-  In your ViewGroup override `https://developer.android.com/reference/android/view/ViewGroup.html#generateLayoutParams(android.util.AttributeSet)` to return
   your LayoutParams.
   

-  In your `https://developer.android.com/reference/android/view/View.html#onMeasure(int, int)` override, you need to implement following
   pattern:
   
  ```
   protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
       mHelper.adjustChildren(widthMeasureSpec, heightMeasureSpec);
       super.onMeasure(widthMeasureSpec, heightMeasureSpec);
       if (mHelper.handleMeasuredStateTooSmall()) {
           super.onMeasure(widthMeasureSpec, heightMeasureSpec);
       }
   }
   
  ```

   

- In your `https://developer.android.com/reference/android/view/ViewGroup.html#onLayout(boolean, int, int, int, int)` override, you need to
   implement following pattern:
   
  ```
   protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
       super.onLayout(changed, left, top, right, bottom);
       mHelper.restoreOriginalParams();
   }
   
  ```

   











Summary






### Nested classes




  
    
      `
        
        
        
        
        class`
      
        `https://developer.android.com/reference/android/support/percent/PercentLayoutHelper.PercentLayoutInfo`
        
This class was deprecated
in API level 26.1.0.
use ConstraintLayout and Guidelines for layout support. 
        
    


      
    
    
    
    
      `
        
        
        
        
        interface`
      
        `https://developer.android.com/reference/android/support/percent/PercentLayoutHelper.PercentLayoutParams`
        
This interface was deprecated
in API level 26.1.0.
this class is deprecated along with its parent class. 
        
    


      
    
    
    


























### Public constructors





  
  
  
  
    
      `
      https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#PercentLayoutHelper(android.view.ViewGroup)(https://developer.android.com/reference/android/view/ViewGroup.html host)
      `
      
    
  
  












### Public methods





  
  
  
  
    `
        
        
        
        
        
        void`
    
  
    
      `
      https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#adjustChildren(int, int)(int widthMeasureSpec, int heightMeasureSpec)
      `
      
        
Iterates over children and changes their width and height to one calculated from percentage
 values.
        
    


      
    
  
  

  
  
  
  
    `
        
        
        static
        
        
        void`
    
  
    
      `
      https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#fetchWidthAndHeight(android.view.ViewGroup.LayoutParams, android.content.res.TypedArray, int, int)(https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html params, https://developer.android.com/reference/android/content/res/TypedArray.html array, int widthAttr, int heightAttr)
      `
      
        
Helper method to be called from `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html#setBaseAttributes(android.content.res.TypedArray, int, int)` override
 that reads layout_width and layout_height attribute values without throwing an exception if
 they aren't present.
        
    


      
    
  
  

  
  
  
  
    `
        
        
        static
        
        
        https://developer.android.com/reference/android/support/percent/PercentLayoutHelper.PercentLayoutInfo`
    
  
    
      `
      https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#getPercentLayoutInfo(android.content.Context, android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)
      `
      
        
Constructs a PercentLayoutInfo from attributes associated with a View.
        
    


      
    
  
  

  
  
  
  
    `
        
        
        
        
        
        boolean`
    
  
    
      `
      https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#handleMeasuredStateTooSmall()()
      `
      
        
Iterates over children and checks if any of them would like to get more space than it
 received through the percentage dimension.
        
    


      
    
  
  

  
  
  
  
    `
        
        
        
        
        
        void`
    
  
    
      `
      https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#restoreOriginalParams()()
      `
      
        
Iterates over children and restores their original dimensions that were changed for
 percentage values.
        
    


      
    
  
  













### Inherited methods






  https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#From
class
`
  
    java.lang.Object
  
`

  
  
  
    
|---|---|
| ` Object` | ` clone() ` |
| ` boolean` | ` equals(Object arg0) ` |
| ` void` | ` finalize() ` |
| ` final Class<?>` | ` getClass() ` |
| ` int` | ` hashCode() ` |
| ` final void` | ` notify() ` |
| ` final void` | ` notifyAll() ` |
| ` String` | ` toString() ` |
| ` final void` | ` wait(long arg0, int arg1) ` |
| ` final void` | ` wait(long arg0) ` |
| ` final void` | ` wait() ` |


  
























Public constructors






    
### PercentLayoutHelper


    
      
    added in https://developer.android.com/topic/libraries/support-library/revisions
      
  

    

```
PercentLayoutHelper (ViewGroup host)
```

    
    

    
  
<br />



<br />



    
| Parameters ||
|---|---|
| `host` | `ViewGroup` <br /> |

















Public methods






    
### adjustChildren


    
      
    added in https://developer.android.com/topic/libraries/support-library/revisions
      
  

    

```
void adjustChildren (int widthMeasureSpec, 
                int heightMeasureSpec)
```

    
    

    
  
Iterates over children and changes their width and height to one calculated from percentage
 values.

<br />



    
| Parameters ||
|---|---|
| `widthMeasureSpec` | `int`: Width MeasureSpec of the parent ViewGroup. <br /> |
| `heightMeasureSpec` | `int`: Height MeasureSpec of the parent ViewGroup. <br /> |









    
### fetchWidthAndHeight


    
      
    added in https://developer.android.com/topic/libraries/support-library/revisions
      
  

    

```
void fetchWidthAndHeight (ViewGroup.LayoutParams params, 
                TypedArray array, 
                int widthAttr, 
                int heightAttr)
```

    
    

    
  
Helper method to be called from `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html#setBaseAttributes(android.content.res.TypedArray, int, int)` override
 that reads layout_width and layout_height attribute values without throwing an exception if
 they aren't present.


<br />



    
| Parameters ||
|---|---|
| `params` | `ViewGroup.LayoutParams` <br /> |
| `array` | `TypedArray` <br /> |
| `widthAttr` | `int` <br /> |
| `heightAttr` | `int` <br /> |









    
### getPercentLayoutInfo


    
      
    added in https://developer.android.com/topic/libraries/support-library/revisions
      
  

    

```
PercentLayoutHelper.PercentLayoutInfo getPercentLayoutInfo (Context context, 
                AttributeSet attrs)
```

    
    

    
  
Constructs a PercentLayoutInfo from attributes associated with a View. Call this method from
 `LayoutParams(Context c, AttributeSet attrs)` constructor.


<br />



    
| Parameters ||
|---|---|
| `context` | `Context` <br /> |
| `attrs` | `AttributeSet` <br /> |


    
| Returns ||
|---|---|
| `https://developer.android.com/reference/android/support/percent/PercentLayoutHelper.PercentLayoutInfo` | <br /> |









    
### handleMeasuredStateTooSmall


    
      
    added in https://developer.android.com/topic/libraries/support-library/revisions
      
  

    

```
boolean handleMeasuredStateTooSmall ()
```

    
    

    
  
Iterates over children and checks if any of them would like to get more space than it
 received through the percentage dimension.

 If you are building a layout that supports percentage dimensions you are encouraged to take
 advantage of this method. The developer should be able to specify that a child should be
 remeasured by adding normal dimension attribute with `wrap_content` value. For example
 he might specify child's attributes as `app:layout_widthPercent="60%p"` and
 `android:layout_width="wrap_content"`. In this case if the child receives too little
 space, it will be remeasured with width set to `WRAP_CONTENT`.

<br />



    
| Returns ||
|---|---|
| `boolean` | True if the measure phase needs to be rerun because one of the children would like to receive more space. <br /> |









    
### restoreOriginalParams


    
      
    added in https://developer.android.com/topic/libraries/support-library/revisions
      
  

    

```
void restoreOriginalParams ()
```

    
    

    
  
Iterates over children and restores their original dimensions that were changed for
 percentage values. Calling this method only makes sense if you previously called
 `https://developer.android.com/reference/android/support/percent/PercentLayoutHelper#adjustChildren(int, int)`.


<br />
















````
-

  ## Interfaces

  - [PercentLayoutHelper.PercentLayoutParams](https://developer.android.com/reference/android/support/percent/PercentLayoutHelper.PercentLayoutParams)
-

  ## Classes

  - [PercentFrameLayout](https://developer.android.com/reference/android/support/percent/PercentFrameLayout)
  - [PercentFrameLayout.LayoutParams](https://developer.android.com/reference/android/support/percent/PercentFrameLayout.LayoutParams)
  - [PercentLayoutHelper](https://developer.android.com/reference/android/support/percent/PercentLayoutHelper)
  - [PercentLayoutHelper.PercentLayoutInfo](https://developer.android.com/reference/android/support/percent/PercentLayoutHelper.PercentLayoutInfo)
  - [PercentRelativeLayout](https://developer.android.com/reference/android/support/percent/PercentRelativeLayout)
  - [PercentRelativeLayout.LayoutParams](https://developer.android.com/reference/android/support/percent/PercentRelativeLayout.LayoutParams)
  - [R](https://developer.android.com/reference/android/support/percent/R)
  - [R.attr](https://developer.android.com/reference/android/support/percent/R.attr)
  - [R.bool](https://developer.android.com/reference/android/support/percent/R.bool)
  - [R.color](https://developer.android.com/reference/android/support/percent/R.color)
  - [R.dimen](https://developer.android.com/reference/android/support/percent/R.dimen)
  - [R.drawable](https://developer.android.com/reference/android/support/percent/R.drawable)
  - [R.id](https://developer.android.com/reference/android/support/percent/R.id)
  - [R.integer](https://developer.android.com/reference/android/support/percent/R.integer)
  - [R.layout](https://developer.android.com/reference/android/support/percent/R.layout)
  - [R.string](https://developer.android.com/reference/android/support/percent/R.string)
  - [R.style](https://developer.android.com/reference/android/support/percent/R.style)
  - [R.styleable](https://developer.android.com/reference/android/support/percent/R.styleable)