QR code control

master
dtvv 2018-10-31 15:25:36 -06:00
parent f4759abc72
commit 04191b309d
1 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package cy.agorise.crystalwallet.util
import android.content.Context
import android.support.v7.widget.AppCompatImageView
import android.util.AttributeSet
/**
* Created by xd on 1/24/18.
* ImageView which adjusts its size to always create a square
*/
class SquaredImageView : AppCompatImageView {
constructor(context: Context) : super(context) {}
constructor(context: Context, @Nullable attrs: AttributeSet) : super(context, attrs) {}
constructor(context: Context, @Nullable attrs: AttributeSet, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
) {
}
protected fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
val size = Math.min(getMeasuredWidth(), getMeasuredHeight())
setMeasuredDimension(size, size)
}
}