I have created a new activity but the status bar
is hidden, I want to show
Here is my activity
code
class TurnsActivity : ToolbarActivity() {
val fragmentAdapter = PageAdapterTurns(supportFragmentManager)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_turns)
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN)
toolbarToLoad(toolbar as Toolbar)
view_pager.adapter = fragmentAdapter
tab.setupWithViewPager(view_pager)
tab.getTabAt(0)!!.setIcon(R.drawable.ic_sun)
tab.getTabAt(1)!!.setIcon(R.drawable.ic_moon)
}
}
but activty is:
Remove these two lines from onCreate()
:
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN)
Check your res -> values -> styles.xml
and Remove any line in your AppTheme that refers to StatusBar:
A normal AppTheme looks like this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Check your AndroidManifest.xml
and remove any theme applied to your Activity
<activity android:name=".YourActivity">
...
</activity>
delete these codes
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN) window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN)
solved, status bar color was white instead hidden so I changed it
window.statusBarColor = resources.getColor(R.color.colorAccent)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.