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内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复