Java
[Android/Kotiln] 태블릿판별, 태블릿 아닐 때만 세로 모드 고정
딩신
2021. 1. 27. 19:33
fun isTablet(context: Context): Boolean {
val xlarge = context.getResources().getConfiguration().screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK === Configuration.SCREENLAYOUT_SIZE_XLARGE
val large = context.getResources().getConfiguration().screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK === Configuration.SCREENLAYOUT_SIZE_LARGE
return xlarge || large
} // 세로 모드 고정
public override fun onCreate(savedInstanceState: Bundle?) {
if(!isTablet(this)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
}
.....