隐藏Android的标题栏,仅在横向模式下
问题描述:
我有一个活动,要具备这些条件:隐藏Android的标题栏,仅在横向模式下
- 我的活动在纵向模式下的标题栏。
- 当我将设备转到横向模式时,标题栏会隐藏。
- 通过在Manifest中使用“configChanges”,当进入风景模式时,不应该重新创建活动。
我知道这个问题之前被问过,但没有找到正确的答案。
请帮帮忙,在此先感谢...
答
添加在style.xml
<style name="generalnotitle" parent="Theme.AppCompat.Light" >
<item name="android:windowNoTitle">true</item> <!-- //this -->
</style>
加入manifiest文件活动,
android:theme="@style/generalnotitle">
要获得设备的方向
int display_mode = getResources().getConfiguration().orientation;
if (display_mode == Configuration.ORIENTATION_LANDSCAPE) {
getSupportActionBar().hide(); //<< this
} else {
}
setContentView(R.layout.activity_main);
风景模式
你尝试过这么远吗? –
您可以通过configChanges回调隐藏标题栏,就像您在横向模式中提到的那样 – kirtan403
我已经使用: android:configChanges =“orientation | screenSize” 在清单中停止重新创建更改屏幕方向后的活动。 – Arantik