I try to use a PercentFrameLayout but I get this error message:
Binary XML file line #: You must supply a layout_width attribute.
This is the xml I use:
<android.support.percent.PercentFrameLayout
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_heightPercent="50%"
app:layout_marginLeftPercent="25%"
app:layout_marginTopPercent="25%"
app:layout_widthPercent="50%"/>
</android.support.percent.PercentFrameLayout>
Is this a bug or is it my mistake?
The
layout_width
andlayout_height
attributes are still required due to the XML layout specifications, but are effectively ignored in aPercentFrameLayout
orPercentRelativeLayout
.You just have to set the values to
0dp
orwrap_content
:This is similar to the usage of a standard
LinearLayout
withlayout_weight
where you have to specify alayout_width
too.