Wie Symbolleiste in meinem Fall beim Scrollen ausblenden? Ich habe Activty mit Schublade und verschachtelten Fragmenten. Ich brauche die Symbolleiste beim Scrollen in Pages ausblenden. Wie geht das? Bitte hilf mir.Wie kann ich die Werkzeugleiste ausblenden, wenn ich im Fragment blättern möchte?
P.S: Sorry für mein Englisch bitte.
Aktivität Layout:
<?xml version="1.0" encoding="utf-8"?>
<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:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/app_nav_header_main"
app:menu="@menu/main_drawer" />
</android.support.v4.widget.DrawerLayout>
app_bar_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
content_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/app_bar_main"/>
Fragment mit TabLayout und ViewPager:
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/flipper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@layout/layout_please_wait"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="2dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/AppTheme.AppBarOverlay"
app:tabIndicatorColor="@android:color/white" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
<include
layout="@layout/layout_no_internet"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ViewFlipper>
Seite Fragment:
<?xml version="1.0" encoding="utf-8"?>
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/flipper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/layout_please_wait" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refresh"
android:layout_margin="5dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/newsList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="@android:color/transparent"
android:divider="@null"
android:dividerHeight="10dp"
android:listSelector="@android:color/transparent" />
</android.support.v4.widget.SwipeRefreshLayout>
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
layout="@layout/layout_news_empty" />
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
layout="@layout/layout_no_internet" />
</ViewFlipper>
Die Frage hier sieht aus wie es gutes Beispiel hat, sollte mit dem einen kleinen Fix in der Antwort beschrieben funktionieren: http://stackoverflow.com/questions/33132908/drawerlayout-collapsingtoolbar-fragments-toolbar-wont-collapse-or -show-ima –
@Daniel Nugent, thx. Aber das hat nicht für mich funktioniert. Vielleicht weil ich ein ListView im Fragment verwende? Ich füge gerade App hinzu: layout_collapseMode = "pin", aber tihs hat mich nicht gehackt :( – GPPSoft
Ein Vorschlag. Versuchen Sie, die Registerkarte wie in diesem https://github.com/chrisbanes/cheesesquare Beispiel zu platzieren. – razzledazzle