Created
April 9, 2018 23:26
-
-
Save cscouto/328d1e03f90c3c8245f3ef7be36786a5 to your computer and use it in GitHub Desktop.
KOTLIN - Class to make a squared size item for you recyclerview grid layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.annotation.TargetApi | |
import android.content.Context | |
import android.os.Build | |
import android.util.AttributeSet | |
import android.widget.RelativeLayout | |
/** | |
* Created by docouto on 4/9/18. | |
*/ | |
class SquareLayout : RelativeLayout { | |
constructor(context: Context) : super(context) {} | |
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {} | |
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {} | |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | |
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { | |
} | |
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { | |
// Set a square layout. | |
super.onMeasure(widthMeasureSpec, widthMeasureSpec) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment