android - 如何在滚动时修复 ConstraintLayout 中的视图?
问题描述
我有一个layout
可滚动的。我需要ImageView
在父级的右下角放置一个ImageView
位置,即使在滚动时也应该固定到该位置。下面是我写的代码。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/random_text"
android:textSize="20dp"
app:layout_constraintRight_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/back_to_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/back_to_top"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
但是它ImageView
可以随着内容滚动而不是固定的。如何实现这一点ConstraintLayout
?一种解决方案是将其放在ImageView
外部ConstraintLayout
,但将其放在内部时是否有任何地方可以实现它ConstraintLayout
。
注意:这是一个非常简单的布局,是我为发布问题而编造的。真正的布局更复杂,但也有同样的问题。
解决方案
推荐阅读
- c++ - 如何在控制台c ++中制作加载栏
- c# - 如何访问这些 C# 对象的属性?
- javascript - JS,从数组中取出一个连续相同的特定元素
- python - django urls() 以 10 为底的 int() 的无效文字:
- java - 试图将两个数组组合成一个排序数组;当第一个数组小于第二个数组时,代码不起作用
- python - 为 sklearn 管道构建 Transformer - 用 KNN 预测替换空值
- python - 将总金额转换为单独的账单 Python
- ios - 无法使用服务 UUID 发现外围设备
- docker - 无法启动 mariaDB Docker 挂载特定目录
- css - 发现很难让堆叠的 div 响应