Android 利用ConstraintLayout约束banner 比例显示,glide加载圆角

<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);

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容