8

Tôi muốn thanh công cụ (thanh tác vụ) ẩn hoàn toàn khi cuộn xuống. Khi khởi chạy hoạt động hoặc cuộn lại thanh công cụ sẽ hiển thị và thanh trạng thái sáng màu xám.Thanh công cụ sẽ không cuộn dưới thanh trạng thái trong suốt

  1. bắt đầu bằng [statusbar | thanh công cụ | content]
  2. cuộn xuống [co- (thanh trạng thái) -ntent]
  3. cuộn lên [thanh trạng thái | thanh công cụ | nội dung]
hiện

:

  1. khi khởi động/khởi động startup/boot

  2. cuộn nội dung xuống Scrolled content down

  3. cuộn nội dung lên Scrolled content up

activity_layout.xml

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/background_white" 
tools:context="com.conevoud.captjeluigi.ui.activities.GalleryActivity"> 

<android.support.design.widget.CoordinatorLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <FrameLayout 
     android:id="@+id/content_frame" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

    <include layout="@layout/toolbar" /> 

</android.support.design.widget.CoordinatorLayout> 

<include layout="@layout/drawer_left" /> 

</android.support.v4.widget.DrawerLayout> 

toolbar.xml

<merge xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/toolbar_frame" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     app:layout_scrollFlags="scroll|enterAlways" 
     app:popupTheme="?popup_theme" 
     app:theme="@style/ThemeOverlay.AppCompat.ActionBar" /> 

</android.support.design.widget.AppBarLayout> 
</merge> 

phong cách:

<item name="windowActionModeOverlay">true</item> 

    <item name="android:windowTranslucentNavigation">true</item> 
    <item name="android:windowTranslucentStatus">true</item> 

cảm ơn bạn đã đọc.

+0

Bất kỳ may mắn sửa chữa này? – SqueezyMo

+1

Tôi tìm thấy giải pháp, ai đó vẫn muốn biết? – ThirdMartian

+0

có, vui lòng. @ThirdMartian –

Trả lời

0

Trước đây, tôi đã gặp phải vấn đề về sin, hãy thử đặt android:fitsSystemWindows=”true” trong AppBarLayout của bạn.

<android.support.design.widget.AppBarLayout 
    android:id="@+id/toolbar_frame" 
    android:fitsSystemWindows=”true” 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     app:layout_scrollFlags="scroll|enterAlways" 
     app:popupTheme="?popup_theme" 
     app:theme="@style/ThemeOverlay.AppCompat.ActionBar" /> 

</android.support.design.widget.AppBarLayout> 
0

Tôi gặp vấn đề tương tự. Tôi đã được giải quyết.

  1. Đã thêm android:fitsSystemWindows="true" to the AppBarLayout.
  2. Added app:layout_scrollFlags="scroll|enterAlways|snap" cho Toolbar

Dưới đây là cách bố trí tôi đã có.

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".HomeActivity"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fitsSystemWindows="true" 
    android:theme="@style/AppTheme.AppBarOverlay"> 
     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|enterAlways|snap" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/id_tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"/> 

</android.support.design.widget.AppBarLayout> 

<android.support.v4.view.ViewPager 
    android:id="@+id/id_viewpager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|end" 
    android:layout_margin="@dimen/fab_margin" 
    android:src="@android:drawable/ic_dialog_email"/> 

0

nó trông giống như lựa chọn duy nhất là - thoát khỏi

<item name="android:statusBarColor">@android:color/transparent</item> 

tài sản

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