有没有一种方法可以将scrollview中的元素适合其大小?
我的布局看起来像这样:
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/main_part"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:id="@+id/main_content_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/featured_vp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/view_pager_nav_fragment"
android:layout_below="@id/featured_vp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="50dp" />
</RelativeLayout>
<AnotherContent>...</AnotherContent>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
问题是:最容易使RelativElayout最容易容纳我的正面内容以适合ScrollView?
我已经尝试通过更改RelativElayout的更改布局paranms来实现这一目标,但是通过这种方式,ViewPager在布局中获取了所有空间,尽管Min_heigt为50dp,但它仍会杀死我的FragmentContainerview。
My layout looks like this:
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/main_part"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:id="@+id/main_content_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/featured_vp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/view_pager_nav_fragment"
android:layout_below="@id/featured_vp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="50dp" />
</RelativeLayout>
<AnotherContent>...</AnotherContent>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
Question is: which way is easiest to make RelativeLayout that holds my front content to fit scrollview?
I've try to achieve that programmaticly by change LayoutParanms of RelativeLayout but this way viewpager get all space inside layout, it kills my FragmentContainerView despite its min_heigt is 50dp.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论