Ich versuche Kollabieren Symbolleiste mit TabLayout zu machen, wie folgtEinstürzen Symbolleiste mit TabLayout nicht Toolbar zeigt
https://i.stack.imgur.com/76m5h.gif
aber mein Ergebnis ist wie diese
, wie Sie die Symbolleiste nicht sehen können, zeigt überhaupt. in java Ich gründe Symbolleiste als ActionBar mit
setSupportActionBar(toolbar);
Ich habe versucht, viele so Antworten und andere Websites, aber nicht in der Lage, mein Problem zu lösen.
unten ist das XML, das ich verwende.
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bg_main"
android:orientation="vertical">
<com.gigamole.navigationtabstrip.NavigationTabStrip
android:id="@+id/nts_strip"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="top"
android:background="@color/colorPrimary"
app:layout_collapseMode="parallax"
app:nts_active_color="@color/white"
app:nts_animation_duration="300"
app:nts_color="@color/white"
app:nts_corners_radius="1.5dp"
app:nts_inactive_color="@color/white_transparent"
app:nts_titles="@array/nts_titles" />
<android.support.v4.view.ViewPager
android:id="@+id/pager_photos"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/white_transparent" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
hier ist die styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
Bitte lassen Sie mich wissen, wenn Sie etwas anderes.
Haben Sie die 'Toolbar' auf der Java-Seite initialisiert? Was sind deine 'Styles.xml' Codes? – Mohsen
Das ist seltsam, können Sie versuchen, das 'Layout' ohne die' NavigationTabStrip' und keine 'LinearLayout', nur ein' ViewPager' und lassen Sie es mich wissen? – Mohsen
@Mohsen das Problem ist Symbolleiste nicht sichtbar, warum schlagen Sie vor, lineares Layout zu entfernen ?? Können Sie einen gültigen Grund angeben? – SaravInfern