【发布时间】:2019-09-12 16:53:47
【问题描述】:
所以我有一个带有ScrollView 的布局。当我测试我的代码时,ViewPager-heigth 从一个合理的值(1845)跳到非常小(眼睛看不到的速度如此之快)。如果我将ViewPager 的layout_height 切换为wrap_content,高度会跳到0。
此外,当ViewPager 的高度 > 0 时,它的上半部分在屏幕之外,只有下半部分可见。
显然我在这里做错了:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="@color/colorDeadBackground"
android:fillViewport="true">
<LinearLayout
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:outlineProvider="bounds"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:elevation="2dp"
app:cardCornerRadius="6dp">
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager_pics"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<com.finder.ViewPagerIndicator.LinePageIndicator
android:id="@+id/indicator"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginTop="4dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
app:strokeWidth="2dp"
app:unselectedColor="#88888888"
app:selectedColor="@color/colorWhite"/>
</androidx.cardview.widget.CardView>
...
如果我将高度设置为固定值(以编程方式或在 xml 中),问题仍然存在,只有 ViewPager 的上半部分可见。甚至预览窗口也只显示了它在屏幕上的一半:
【问题讨论】:
标签: android scrollview