• <legend id='idUSl'><style id='idUSl'><dir id='idUSl'><q id='idUSl'></q></dir></style></legend>
    <tfoot id='idUSl'></tfoot>
        <i id='idUSl'><tr id='idUSl'><dt id='idUSl'><q id='idUSl'><span id='idUSl'><b id='idUSl'><form id='idUSl'><ins id='idUSl'></ins><ul id='idUSl'></ul><sub id='idUSl'></sub></form><legend id='idUSl'></legend><bdo id='idUSl'><pre id='idUSl'><center id='idUSl'></center></pre></bdo></b><th id='idUSl'></th></span></q></dt></tr></i><div id='idUSl'><tfoot id='idUSl'></tfoot><dl id='idUSl'><fieldset id='idUSl'></fieldset></dl></div>

        <small id='idUSl'></small><noframes id='idUSl'>

        • <bdo id='idUSl'></bdo><ul id='idUSl'></ul>

        使用 CollapsingToolbarLayout 时没有出现 Viewpager

        时间:2023-10-04

          <i id='jPSmR'><tr id='jPSmR'><dt id='jPSmR'><q id='jPSmR'><span id='jPSmR'><b id='jPSmR'><form id='jPSmR'><ins id='jPSmR'></ins><ul id='jPSmR'></ul><sub id='jPSmR'></sub></form><legend id='jPSmR'></legend><bdo id='jPSmR'><pre id='jPSmR'><center id='jPSmR'></center></pre></bdo></b><th id='jPSmR'></th></span></q></dt></tr></i><div id='jPSmR'><tfoot id='jPSmR'></tfoot><dl id='jPSmR'><fieldset id='jPSmR'></fieldset></dl></div>
                <bdo id='jPSmR'></bdo><ul id='jPSmR'></ul>

                <small id='jPSmR'></small><noframes id='jPSmR'>

                  <legend id='jPSmR'><style id='jPSmR'><dir id='jPSmR'><q id='jPSmR'></q></dir></style></legend>
                    <tbody id='jPSmR'></tbody>
                  <tfoot id='jPSmR'></tfoot>
                1. 本文介绍了使用 CollapsingToolbarLayout 时没有出现 Viewpager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我一直在玩设计支持库,遇到了一个小问题,希望有人能帮我解决.

                  I've been playing around with the Design Support Library and have come across a little problem that I hope someone can help me out with.

                  我正在使用一个 CollapsingToolbar,其中包含一个在 parralax 中折叠的 ImageView.在 CollapsingToolbar 中,我还有一个 TabLayout,它应该可以滚动我的 ViewPager.我的问题是 ViewPager 没有出现.只有当我将 ViewPager layout_height 设置为 match_parent 或 wrap_content 时,才会出现此问题.如果我将它设置为 600dp,那么问题就消失了,但是视图最终变成了一个固定的长度,这不是很好.

                  I'm using a CollapsingToolbar which contain an ImageView which collapses in parralax. In the CollapsingToolbar, I alse have a TabLayout which is supposed to scroll my ViewPager. My issue is that the ViewPager doesn't appear. The issue seems to arise only when I set my ViewPager layout_height to match_parent or wrap_content. If I set it to 600dp, then the problem is gone but then the view ends up being a fixed length which isn't very nice.

                  任何帮助将不胜感激!

                  这是我的 XML

                  <android.support.design.widget.CoordinatorLayout
                    xmlns:android="http://schemas.android.com/apk/res/android"
                    xmlns:app="http://schemas.android.com/apk/res-auto"
                    android:id="@+id/main_content"
                    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="@dimen/detail_backdrop_height"
                      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                      android:fitsSystemWindows="true"
                      >
                  
                      <android.support.design.widget.CollapsingToolbarLayout
                          android:id="@+id/collapsing_toolbar"
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"
                          app:layout_scrollFlags="scroll|exitUntilCollapsed"
                          android:fitsSystemWindows="true"
                          app:contentScrim="?attr/colorPrimary"
                          >
                  
                          <ImageView
                              android:id="@+id/backdrop"
                              android:layout_width="match_parent"
                              android:layout_height="match_parent"
                              android:fitsSystemWindows="true"
                              app:layout_collapseMode="parallax"
                              android:src="@drawable/stock_image"/>
                  
                          <android.support.v7.widget.Toolbar
                              android:id="@+id/toolbar"
                              android:layout_width="match_parent"
                              android:layout_height="?attr/actionBarSize"
                              app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                              android:layout_gravity="top"
                              />
                  
                          <android.support.design.widget.TabLayout
                              android:id="@+id/tabs"
                              android:layout_width="match_parent"
                              android:layout_height="wrap_content"
                              android:layout_gravity="bottom"/>
                  
                      </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">
                  
                      <LinearLayout
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"
                          android:orientation="vertical"
                          >
                  
                          <android.support.v4.view.ViewPager
                              android:id="@+id/viewpager"
                              android:layout_width="match_parent"
                              android:layout_height="match_parent"
                              android:background="@android:color/white"
                              app:layout_behavior="@string/appbar_scrolling_view_behavior"
                              />
                      </LinearLayout>
                    </android.support.v4.widget.NestedScrollView>
                  
                  </android.support.design.widget.CoordinatorLayout>
                  

                  推荐答案

                  您应该删除 CoordinatorLayoutViewPager:

                  <android.support.design.widget.CoordinatorLayout>
                    <android.support.design.widget.AppBarLayout>
                        ...
                    </android.support.design.widget.AppBarLayout>
                  
                    <android.support.v4.view.ViewPager
                      android:id="@+id/viewpager"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:background="@android:color/white"
                      app:layout_behavior="@string/appbar_scrolling_view_behavior" />
                  
                  </android.support.design.widget.CoordinatorLayout>
                  

                  带有 app:layout_behavior="@string/appbar_scrolling_view_behavior 的视图必须是 CoordinatorLayout 的直接子级,才能相对于 AppBarLayout.

                  The view with app:layout_behavior="@string/appbar_scrolling_view_behavior must be a direct child of CoordinatorLayout to be positioned correctly in relation to the AppBarLayout.

                  这篇关于使用 CollapsingToolbarLayout 时没有出现 Viewpager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                2. <small id='ob03n'></small><noframes id='ob03n'>

                      1. <legend id='ob03n'><style id='ob03n'><dir id='ob03n'><q id='ob03n'></q></dir></style></legend>

                          <bdo id='ob03n'></bdo><ul id='ob03n'></ul>

                            <tbody id='ob03n'></tbody>
                          <tfoot id='ob03n'></tfoot>
                          <i id='ob03n'><tr id='ob03n'><dt id='ob03n'><q id='ob03n'><span id='ob03n'><b id='ob03n'><form id='ob03n'><ins id='ob03n'></ins><ul id='ob03n'></ul><sub id='ob03n'></sub></form><legend id='ob03n'></legend><bdo id='ob03n'><pre id='ob03n'><center id='ob03n'></center></pre></bdo></b><th id='ob03n'></th></span></q></dt></tr></i><div id='ob03n'><tfoot id='ob03n'></tfoot><dl id='ob03n'><fieldset id='ob03n'></fieldset></dl></div>