Alv*_*ban 1 android scrollview android-fragments android-viewpager
我知道在ScrollView中有很多关于ViewPager情况的问题,但是我还没有看到一个描述我所面临的情况的问题.
问题是,当我没有ScrollView时,我的viewPager工作正常,因为它可以在这张照片中看到.

如果我将ScrollView仅用于ViewPager下面的元素,我也会工作,但我不想要这种行为.

当我添加ScrollView时,我可以向上和向下滚动,我也可以向左和向右滑动(为此,我使用这种方法),但随后图像被加载但未显示,因为它可以在下面的图片中看到.

我发现如果,例如,我有四个图像,我在第一个位置看到第一个图像,我可以向右滑动两次(第三个位置),我什么也看不到,但是当我滑动时一次回到左边(第二个位置),我可以看到第二个图像!
不完全确定它是否相关,但方法getCount似乎完全疯了并且不断被称为不停.
XML
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/footer"
android:id="@+id/custom_scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbarFadeDuration="0"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<com.-----.-----.WrapContentHeightViewPager
android:id="@+id/imagePager"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title"
android:textSize="15sp"
android:paddingTop="15dp"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
<TextView
android:id="@+id/tags"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tags"
android:textColor="#ffff44"
android:textSize="13sp"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
Run Code Online (Sandbox Code Playgroud)
我尝试使用不同类型的自定义ScrollViews,但问题仍然存在.我正在使用Android 4.4的Nexus 4进行测试
@AlvaroSantisteban很高兴我可以帮忙.我自己也很挣扎.这一切都归结为理解布局如何工作,更具体地说是理解wrap_content和match_parent.所以这是最初的解决方案:
您的ViewPager应该具有固定的高度,考虑它在ScrollView中.
| 归档时间: |
|
| 查看次数: |
4494 次 |
| 最近记录: |