我是靠谱客的博主 清爽大碗,这篇文章主要介绍Android:图片显示为正方形,现在分享给大家,希望可以做个参考。

public class SquareImageView extends androidx.appcompat.widget.AppCompatImageView {
public SquareImageView(@NonNull Context context) {
super(context);
}
public SquareImageView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public SquareImageView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}
}

使用:


<com.x.x.recruitment.widget.SquareImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:background="@drawable/pic_qr_code" />

 

最后

以上就是清爽大碗最近收集整理的关于Android:图片显示为正方形的全部内容,更多相关Android内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(73)

评论列表共有 0 条评论

立即
投稿
返回
顶部