cra*_*xel 4 android android-layout android-scrollview
我有一个我无法弄清楚的奇怪行为 - 我试图将视图粘贴到滚动视图的底部,但没有运气。我已经尝试过 ClipToPadding 和 fillViewport 但没有一个有帮助。有什么帮助吗?我的 xml 布局是 -
<LinearLayout>
<FrameLayout/>
<ScrollView>
<LinearLayout>
<LinearLayout/>
<RelativeLayout/> <-- This is the problematic view
</LinearLayout>
</ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我想将相对布局粘在底部,即使滚动视图比屏幕长度短,当clipToPadding设置为false时,它确实适合屏幕,但是相对布局只是放在屏幕中间的线性布局之后,当我在滚动视图上将 fillviewport 设置为 true (并删除 Cliptopadding),滚动视图比屏幕长但不可滚动,这导致相对布局“不可见”,有什么建议吗?
小智 8
您可以尝试在 ScrollView 中使用 ConstraintLayout:
\n\n<ScrollView\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:fillViewport="true">\n\n<androidx.constraintlayout.widget.ConstraintLayout\n android:layout_width="match_parent"\n android:layout_height="wrap_content">\n\n \xe2\x80\xa6 Some elements with Constraints \xe2\x80\xa6\n\n <TextView\n android:id="@+id/last_but_one_element\xe2\x80\x9d\n android:layout_width="0dp"\n android:layout_height="wrap_content"\n app:layout_constraintEnd_toEndOf="parent"\n app:layout_constraintStart_toStartOf="parent" \n app:layout_constraintBottom_toTopOf="@+id/some_previous_element"\n app:layout_constraintTop_toBottomOf="@+id/last_element"\n android:layout_marginBottom=\xe2\x80\x9c40dp"\n app:layout_constraintVertical_bias="0.1"/>\n\n <Button\n android:id="@+id/last_element\xe2\x80\x9d\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n app:layout_constraintStart_toStartOf="parent"\n app:layout_constraintEnd_toEndOf="parent"\n app:layout_constraintBottom_toBottomOf="parent"/>\n\n</androidx.constraintlayout.widget.ConstraintLayout>\n
Run Code Online (Sandbox Code Playgroud)\n\n\n