<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.youth.banner.Banner
android:layout_width="match_parent"
android:id="@+id/banner"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintDimensionRatio="h,16:9"
android:layout_height="0dp">
</com.youth.banner.Banner>
</android.support.constraint.ConstraintLayout>
因为初次接触使用此View ,其中layout_constraintDimensionRatio 说明约束的比例 ,参数 h,16:9,意思是约束高,按照宽的9/16显示。h和w之间的关系:h = w * ratio;需要注意的是约束宽或高,只需要,设置宽或高为 0dp,设置match_parent不会起到作用