问题描述
我需要有一个ViewPager内的滚动型,但ViewPager只是当它在滚动型,一切都很好,当我不使用滚动型不会出现。
我已经看到了这样的被问这里的计算器或其他网站上,所有的人都已经回答了你必须把 Android的几个问题:fillViewport =真正的
你的滚动视图来解决这个问题,但对我这个解决方案行不通,ViewPager仍然没有,即使我有出现安卓fillViewport =真正的
在我滚动视图。
我想的东西得到了在Android的API或东西,这个解决方案行不通了改变,没有人知道我怎么可能作出viewpager出现在滚动视图?
更新:一个工作滚动型布局XML:
<滚动型
机器人:ID =@ + ID / scrollView1
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:fillViewport =真正的>
<的LinearLayout
机器人:ID =@ + ID / linearLayout1
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:方向=垂直>
< android.support.v4.view.ViewPager
机器人:ID =@ + ID / itemsViewPager2
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT>
< /android.support.v4.view.ViewPager>
< / LinearLayout中>
< /滚动型>
我跑进了过去类似的问题。 A查看,传呼机必须有一组高(它不能完成内容)。由于ViewPager加载单独的页面,而不是一次全部,就不会知道什么是总结的内容,其实就是。设置layout_height到FILL_PARENT或一组DP允许ViewPager静态地设置它的高度和其他布局内的反应更相应。
I need to have a ViewPager inside a ScrollView but ViewPager just does not appear when its in ScrollView, everything is ok when i dont use ScrollView.
I've seen a couple questions like this being asked here on stackoverflow or on other sites and all of them have been answered that you have to put android:fillViewport="true"
to your scrollview to fix the problem, but this solution doesnt work for me, ViewPager still does not appear even if i have android:fillViewport="true"
in my scrollview.
I guess something got changed in the android api's or something and this solution doesnt work anymore, does anyone know how i could possibly make a viewpager appear in a scrollview?
UPDATE: A working ScrollView layout XML:
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/itemsViewPager2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</android.support.v4.view.ViewPager>
</LinearLayout>
</ScrollView>
I ran into a similar problem in the past. A View-Pager must have a set height (it cannot wrap-content). Since a ViewPager loads separate pages, and not all at once, it won't know what 'wrap-content' actually means. Setting the layout_height to fill_parent or a set dp allows the ViewPager to statically set it's height and react more accordingly within other layouts.
这篇关于ViewPager在滚动型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!