android – 如何在PercentRelativeLayout中使用layout_aspectRatio?

前端之家收集整理的这篇文章主要介绍了android – 如何在PercentRelativeLayout中使用layout_aspectRatio?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PercentRelativeLayout的观点我试图达成16:9的宽高比.

所以我把这一行放在我的build.gradle文件中:compile’c​​om.android.support:design:23.0.1′

我用这个布局:

  1. <android.support.percent.PercentRelativeLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. android:layout_width="match_parent"
  5. android:layout_height="wrap_content">
  6.  
  7. <ImageView
  8. android:layout_width="match_parent"
  9. app:layout_aspectRatio="178%"
  10. android:scaleType="centerCrop"/>
  11.  
  12. </android.support.percent.PercentRelativeLayout>

问题:

> Android Studio警告我:应该为ImageView定义’layout_height’.
>当我运行我的项目我得到:错误:(15)没有找到属性“layout_aspectRatio”的资源标识符.

那怎么了?

@H_502_16@解决方法
您似乎使用错误的依赖项来尝试包含 @L_404_1@.

正确的(和最新版本)是:

  1. com.android.support:percent:23.1.0

换句话说,声明的依赖应该在你的毕业文件中看起来像这样:

  1. compile 'com.android.support:percent:23.1.0'

猜你在找的Android相关文章