ScrollView中布局显示两个元素,一个标签切换,一个viewpager,布局如下:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tl="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eeeeee"
android:scrollbars="none"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.joint.turman.app.widget.tablayout.SlidingTabLayout
android:id="@+id/frg_mymessage_tabs"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#6D8FB0"
android:paddingLeft="5dp"
android:paddingRight="5dp"
tl:tl_indicator_margin_left="2dp"
tl:tl_indicator_margin_right="2dp"
tl:tl_indicator_style="BLOCK"/>
<android.support.v4.view.ViewPager
android:id="@+id/frg_mymessage_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</ScrollView>
这里需要将scrollview中fillviewport设置为true,并将layout_height设置为match_parent才能使viewpager不会留出空白。如果没有fillviewport属性,在linearlayout中设置layout_height为match_parent是无效的!