简体   繁体   English

我不能在没有工具栏布局的情况下在滚动视图和选项卡布局中使用viewpager?

[英]I am not able to use viewpager inside scroll-view and tab layout without toolbar layout?

I want to use 我想用

<android.support.v4.widget.NestedScrollView
            android:id="@+id/scroll_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/action_bar"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <RelativeLayout
                    android:id="@+id/main_content"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    tools:visibility="gone">

                    <RelativeLayout
                        android:id="@+id/image"
                        android:layout_width="match_parent"
                        android:layout_height="220dp">

                        <ImageView
                            android:id="@+id/cover_image"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:scaleType="centerCrop"/>

                    </RelativeLayout>

                    <RelativeLayout
                        android:id="@+id/tab_layout"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/image"
                        android:background="@color/card_background">

                        <android.support.design.widget.TabLayout
                            android:id="@+id/topTabs"
                            style="@style/TextAppearance.Tab"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            app:tabBackground="@color/bpWhite"
                            app:tabGravity="fill"
                            app:tabMode="fixed"
                            app:tabTextColor="@color/secondary_text_color"
                            custom:tabIndicatorColor="@color/secondary_text_color"
                            custom:tabIndicatorHeight="2dp" />

                        <View
                            android:layout_width="match_parent"
                            android:layout_height="2dp"
                            android:layout_below="@id/topTabs"
                            android:background="@drawable/tab_layout_drop_shadow" />
                    </RelativeLayout>

                    <android.support.v4.view.ViewPager
                        android:id="@+id/viewPager"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_below="@id/tab_layout" />

                </RelativeLayout>
                </RelativeLayout>
</android.support.v4.widget.NestedScrollView>

It is not able to scroll, that view-pager or tab-layout is not able scroll I tried all the ways. 它不能滚动,我尝试过的所有方法都无法滚动view-pager或tab-layout。

1.Disable the touch event in view-pager and enable the touch event for scroll-view. 1.在视图寻呼机中禁用触摸事件,并为滚动视图启用触摸事件。

2.Tried other scroll-views like Nestedscrollview, Parallaxscrollview, Coordinator layout.If I use coordinator layout then not able to change he toolbar. 2.尝试了其他滚动视图,如Nestedscrollview,Parallaxscrollview,Coordinator布局。如果我使用Coordinator布局,则无法更改其工具栏。

  1. I used fillviewport true for all the scrollviews. 我将fillviewport true用于所有滚动视图。 but still it is not able to scroll. 但仍然无法滚动。

Any Other ways to fix the issue. 任何其他解决问题的方法。

您可以在没有工具栏的情况下使用视图寻呼机,但在没有工具栏的情况下不能使用选项卡。

Although it remains unclear, what you are trying to achieve here, there is no problem in the layout, really. 尽管还不清楚,但是您在这里想要实现的目标是,实际上布局没有问题。

If you set up the Design Support Library correctly and 如果您正确设置了设计支持库并且

if you did not mess up your listeners with your attempts to disable some touch events and 如果您没有尝试禁用某些触摸事件而使听众陷入困境,

if you take out the tools:visibility="gone" attribute (in order to show anything that can be scrolled) and 如果您删除了tools:visibility="gone"属性(以显示可以滚动的任何内容),

if you decide on a specific height (or wrap_content ) for the ViewPager and 如果您确定ViewPager的特定高度(或wrap_content ),并且

optionally if you take out the first RelativeLayout s which is unnecessary, (可选)如果您不需要的第一个RelativeLayout

then you should be able to scroll. 那么您应该可以滚动。 At least I am inside the layout editor of Android Studio. 至少我在Android Studio的布局编辑器中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 折叠工具栏无法在标签布局下显示viewpager的内容 - collapse toolbar is not able to show the content of viewpager under tab layout ViewPager 滚动布局行为不适用于工具栏 - ViewPager scroll layout behavior not working with Toolbar 使用NestedScrollView中的Viewpager折叠toolBar布局 - Collapsing toolBar Layout with Viewpager inside NestedScrollView 在Eclipse中将工具栏与选项卡布局一起使用 - Use Toolbar With Tab Layout in Eclipse 使用viewpager折叠ToolBar布局 - Collapsing ToolBar Layout with viewpager 我正在使用片段添加带有 viewPager 的选项卡布局。 该选项卡是动态的,0 个选项卡被禁用,1 个选项卡被启用 - I am adding a tab layout with viewPager using fragments. The tab is dynamic on 0 tab is disabled and on 1 tab is enabled 滚动视图内滚动布局? - scroll view inside scroll layout? viewpager下方的布局未显示在滚动视图中 - layout below viewpager is not showing in scroll view 我不希望折叠的工具栏在协调器布局内全部滚动 - I do not want collapsing toolbar to scroll at all inside coordinator layout 我无法使用片段从我的活动中访问片段布局内的文本视图 - I am not being able to access the text view inside my fragment layout from my Activity using the fragment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM