| package com.example.open.diffusion; | |
| import android.content.Context; | |
| import android.util.AttributeSet; | |
| import android.widget.FrameLayout; | |
| import androidx.annotation.NonNull; | |
| import androidx.annotation.Nullable; | |
| import androidx.appcompat.widget.AppCompatImageView; | |
| /** | |
| * Created by ZTMIDGO 2023/4/1 | |
| */ | |
| public class SquareImageView extends AppCompatImageView { | |
| public SquareImageView( Context context) { | |
| this(context, null); | |
| } | |
| public SquareImageView( Context context, AttributeSet attrs) { | |
| super(context, attrs); | |
| } | |
| protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | |
| int widthSize = MeasureSpec.getSize(widthMeasureSpec); | |
| heightMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY); | |
| super.onMeasure(widthMeasureSpec, heightMeasureSpec); | |
| } | |
| } | |