2016-07-06 88 views
0

您好,我已使用Tablayoutviewpagerviewpager包含listview在我的fragement中。表格布局不起作用

我想要实现的功能滚动标签布局还当我从viewpager

这里滚动列表是我的XML文件

message_frag_layout.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:layout_width="match_parent" 
android:layout_height="match_parent"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     app:tabTextColor="@color/gray" 
     app:tabBackground="@color/tabcolor" 
     app:tabSelectedTextColor="@color/white" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:tabMode="fixed" 
     android:background="@drawable/tab_color_selector" 
     app:tabGravity="fill"/> 
</android.support.design.widget.AppBarLayout> 

<android.support.v4.view.ViewPager 
    android:id="@+id/viewpager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 
<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    app:backgroundTint= "#FFFFFF" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|end" 
    android:layout_margin="@dimen/fab_margin" 
    android:src="@drawable/edit" /> 

f滚动listview时如何滚动选项卡布局rom viewpager

在此先感谢。

回答

1

尝试将整个布局封装在NestedScrollView中。尽管在进行这样的布局时,如果处理不正确,滚动会出现很多问题。

<android.support.v4.widget.NestedScrollView 
android:id="@+id/nested_parent_view" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 
<!-- your layout goes here --> 


<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<android.support.design.widget.AppBarLayout 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

<android.support.design.widget.TabLayout 
    android:id="@+id/tabs" 
    app:tabTextColor="@color/gray" 
    app:tabBackground="@color/tabcolor" 
    app:tabSelectedTextColor="@color/white" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:tabMode="fixed" 
    android:background="@drawable/tab_color_selector" 
    app:tabGravity="fill"/> 

</android.support.design.widget.AppBarLayout> 

<android.support.v4.view.ViewPager 
android:id="@+id/viewpager" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

<android.support.design.widget.FloatingActionButton 
android:id="@+id/fab" 
app:backgroundTint= "#FFFFFF" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="bottom|end" 
android:layout_margin="@dimen/fab_margin" 
android:src="@drawable/edit" /> 


</android.support.v4.widget.NestedScrollView> 
+0

可以编辑我的代码 –

+0

我不知道在哪里放置THA滚动型 –

+0

这样做可以让你的tablayout出去的下面放置在屏幕和显示的内容,如果这是你想要的:) – Kushan