Skip to content

Commit

Permalink
适配高刷
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjianxiandev committed Jul 17, 2020
1 parent aa71339 commit 9077193
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ abstract class BaseActivity : AppCompatActivity() {
}

override fun onCreate(savedInstanceState: Bundle?) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val modes = window.windowManager.defaultDisplay.supportedModes
modes.sortBy {
it.refreshRate
}
window.let {
val layoutParam = it.attributes
layoutParam.preferredDisplayModeId = modes.last().modeId
it.attributes = layoutParam
}
}
super.onCreate(savedInstanceState)
setContentView(getLayoutId())
mRootView = (findViewById(android.R.id.content) as ViewGroup).getChildAt(0)
Expand Down

0 comments on commit 9077193

Please sign in to comment.