I'm trying to use android.support.percent.PercentRelativeLayout
:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
<ImageView
app:layout_widthPercent="70%"
app:layout_aspectRatio="1000%"
app:layout_marginTopPercent="15%"
android:layout_centerHorizontal="true"
android:src="@drawable/logo"/>
</android.support.percent.PercentRelativeLayout>
</ScrollView>
Android Studio gives me errors:
"layout_height should be specified
"layout_width should be specified"
Project is building now, but studio shows errors and do not suggest autocompletion when I start typing "percent..."
What am I doing wrong?
Here is example from official site, why it's not working?
The question was answered here : PercentRelativeLayout - layout_width missing warning
Basically; width and height are ignored by PercentRelativeLayout, but you need to set them to 0dp, because Android Studio expects them to be here.