gpt4 book ai didi

android - Android Studio:即使您在应用程序中滚动,如何创建 View 仍保持锁定状态?

转载 作者:行者123 更新时间:2023-12-02 13:41:11 25 4
gpt4 key购买 nike

有点像标题保持在原位的方式,即使您具有recyclerview并向下滚动也是如此。

最佳答案

您可以像这样使用ConstrainLayout:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<ScrollView
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<TextView
android:text="LONG LONG LONG LONG LONG LONG LONG LONG LONG LONG LONG LONG LONG LONG LONG LONG TEXT"
android:textSize="70sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</ScrollView>

<!--This Button will stay in the same place-->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

关于android - Android Studio:即使您在应用程序中滚动,如何创建 View 仍保持锁定状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63363061/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com