[英]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布局,则无法更改其工具栏。
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.