我有一個活動,要具備這些條件:隱藏Android的標題欄,僅在橫向模式下
- 我的活動在縱向模式下的標題欄。
- 當我將設備轉到橫向模式時,標題欄會隱藏。
- 通過在Manifest中使用「configChanges」,當進入風景模式時,不應該重新創建活動。
我知道這個問題之前被問過,但沒有找到正確的答案。
請幫幫忙,在此先感謝...
我有一個活動,要具備這些條件:隱藏Android的標題欄,僅在橫向模式下
我知道這個問題之前被問過,但沒有找到正確的答案。
請幫幫忙,在此先感謝...
添加在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