<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不会起到作用
//设置图片圆角角度
RoundedCorners roundedCorners = new RoundedCorners(360);
//通过RequestOptions扩展功能,override:采样率,因为ImageView就这么大,可以压缩图片,降低内存消耗
RequestOptions override = RequestOptions.bitmapTransform(roundedCorners).override(300, 300);
Glide.with(mainActivity).load(mlss.get(i).getMasterPic())
.apply(override)
.into(viewHolder.iamge);
网友评论