Subclass of RelativeLayout that supports percentage based dimensions and margins. You can specify dimension or a margin of child by using attributes with "Percent" suffix. The tag is to be used with the [android] tag.
Subclass of RelativeLayout (android-relativelayout) that supports percentage based dimensions and margins. You can specify dimension or a margin of child by using attributes with "Percent" suffix.
Usage:
Please, use the tag jointly with android tag.
Example:
<android.support.percent.PercentRelativeLayout
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"/>
<ImageView
app:layout_widthPercent="50%"
app:layout_heightPercent="50%"
app:layout_marginTopPercent="25%"
app:layout_marginLeftPercent="25%"/>
</android.support.percent.PercentFrameLayout/>
It is not necessary to specify layout_width/height
if you specify layout_widthPercent
. However, if you want the view to be able to take up more space than what percentage value permits, you can add layout_width/height="wrap_content"
.
In that case, if the percentage size is too small for the View's content, it will be resized using wrap_content
rule.
From PercentRelativeLayout:
This class was deprecated in API level 26.1.0.
consider using ConstraintLayout and associated layouts instead.