I try to achieve a 16:9 aspect ratio on a view with the PercentRelativeLayout
.
So I have put this line in my build.gradle file: compile 'com.android.support:design:23.0.1'
I use this layout:
<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="wrap_content">
<ImageView
android:layout_width="match_parent"
app:layout_aspectRatio="178%"
android:scaleType="centerCrop"/>
</android.support.percent.PercentRelativeLayout>
Problems:
- Android Studio warn me with:
'layout_height' should be defined
for theImageView
. - When I run my project I got :
Error:(15) No resource identifier found for attribute 'layout_aspectRatio'
.
So what's wrong ?