<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_constraintDimensionRatio="h,16:9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
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不會起到作用