QR code control
This commit is contained in:
parent
14a6a520c9
commit
4e5ee90605
1 changed files with 30 additions and 0 deletions
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue