2016-01-24 16 views
16

Tôi có hoạt động chuyển sang hoạt động toàn màn hình khác. Tuy nhiên, khi chuyển từ hoạt động này sang hoạt động toàn màn hình của tôi, thanh điều hướng sẽ trượt xuống thay vì biến mất ngay lập tức. Tôi đã thổi phồng một cửa sổ toàn màn hình trong hoạt động thứ hai, nhưng do hoạt ảnh trượt chậm, nó thay đổi kích thước 1 giây sau khi hoạt ảnh đã hoàn thành thay vì bị thổi phồng lên toàn màn hình ngay lập tức. Vì vậy, tôi cần các hình ảnh động để biến mất ngay lập tức. Tôi đã thửLàm thế nào để vô hiệu hóa hoạt hình trượt thanh điều hướng khi đi toàn màn hình?

<item name="android:windowAnimationStyle">@null</item>

overridePendingTransition(0, 0); 

Transition fade = new Fade(); 
fade.excludeTarget(android.R.id.navigationBarBackground, true); 
getWindow().setEnterTransition(fade); 

không có may mắn.

Về phía Windows, tôi đã cố gắng

WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 
WindowManager.LayoutParams.FLAG_FULLSCREEN 
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 

Làm thế nào tôi ẩn navbar: View.SYSTEM_UI_FLAG_HIDE_NAVIGATION

Trả lời

11

Tôi nghĩ rằng, tôi đóng đinh nó:

enter image description here

FullscreenActivity lớp:

public class FullscreenActivity extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     View decorView = getWindow().getDecorView(); 
     int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE 
       | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 
       | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; 
     decorView.setSystemUiVisibility(uiOptions); 
     ActionBar actionBar = getSupportActionBar(); 
     if (actionBar != null) { 
      actionBar.hide(); 
     } 

     setContentView(R.layout.activity_fullscreen); 
    } 
} 

Manifest:

<activity 
     android:name=".FullscreenActivity" 
     android:configChanges="orientation|keyboardHidden|screenSize" 
     android:label="@string/title_activity_fullscreen" 
     android:theme="@style/FullscreenTheme"/> 

Styles:

<style name="FullscreenTheme" parent="AppTheme"> 
    <item name="android:statusBarColor">@android:color/transparent</item> 
    <item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item> 
    <item name="android:windowActionBarOverlay">true</item> 
    <item name="android:windowBackground">@null</item> 
    <item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item> 
    <item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item> 
</style> 

NB! Đặt StatusBar màu được yêu cầu API 21. Đối với các phiên bản cũ, để "che giấu" Statusbar, bạn cần sử dụng:

 int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION 
       | View.SYSTEM_UI_FLAG_FULLSCREEN; 

như uiOptions trong đoạn code trên. (nó sẽ gây ra thay đổi kích thước khá nhanh, mặc dù).

Tôi hy vọng, nó sẽ giúp

Các vấn đề liên quan