1
我的代碼如下所示:崩潰工具欄無法顯示viewpager的標籤下的佈局內容
<?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.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="300dp"
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="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:title="Test">
<ImageView
android:id="@+id/toolbarImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/truck_test"
app:layout_collapseMode="parallax" />
<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>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/tabsMain"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_below="@+id/toolbar"
android:background="@android:color/white"
app:tabGravity="fill"
app:tabIndicatorHeight="5dp"
app:tabMaxWidth="156dp"
app:tabMinWidth="148dp"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/colorRoyalPurple"
app:tabTextColor="@color/colorGray89" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpagerMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tabsMain"
android:background="@color/colorMercuryE1"
android:clipToPadding="false"
android:paddingTop="10dp" />
<LinearLayout
android:id="@+id/showCart"
android:layout_width="match_parent"
android:layout_height="53dp"
android:layout_alignParentBottom="true"
android:background="@color/colorRoyalPurple"
android:orientation="horizontal"
android:visibility="invisible">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/itemCartText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="10dp"
android:text="1"
android:textColor="@android:color/white"
android:textSize="12sp" />
<TextView
android:id="@+id/viewCart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="View Cart"
android:textColor="@android:color/white"
android:textSize="15sp" />
</LinearLayout>
<ImageView
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:background="@drawable/icon_arrow" />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
現在,我在這裏能夠成功加載的標籤,但不知何故,裏面的內容片段不得到加載。 It hows like this。所以我怎樣才能在tab佈局下顯示viewpager?
移動你的tablayout代碼appbar佈局 –
不,它確實沒有工作。如果我將標籤佈局移動到appbar佈局,它會粘在頂部,視差效果消失 –
那麼您需要準確嗎? –