将TextView和ScrollView放在其他两个视图(页眉和页脚)之间

测试仪

我想在ScrollView中有一个可滚动的TextView / TextView。

我已经尝试过并查找了多个页面,但是我的问题始终是,尽管进入“ ScrollMode”,但表示“某些文本”的文本“ text” TextView总是超出了其他两个视图之间的空间

这是我的XML代码:

<?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">
<ImageView
    android:id="@+id/imageView"
    android:layout_width="150dp"
    android:layout_height="150dp"
    android:layout_marginStart="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginTop="40dp"
    android:layout_marginEnd="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginBottom="8dp"
    app:layout_constraintBottom_toTopOf="@+id/title"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<TextView
    android:id="@+id/title"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginStart="32dp"
    android:layout_marginLeft="32dp"
    android:layout_marginTop="45dp"
    android:layout_marginEnd="32dp"
    android:layout_marginRight="32dp"
    android:gravity="center_horizontal"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/imageView"
    tools:targetApi="jelly_bean" />

<ScrollView
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="32dp"
    android:layout_marginLeft="32dp"
    android:layout_marginTop="32dp"
    android:layout_marginEnd="32dp"
    android:layout_marginRight="32dp"
    android:layout_marginBottom="32dp"
    android:orientation="vertical"
    app:layout_constraintBottom_toTopOf="@+id/linearLayout"
    app:layout_constraintEnd_toEndOf="@+id/title"
    app:layout_constraintStart_toStartOf="@+id/title"
    app:layout_constraintTop_toBottomOf="@+id/title">

    <TextView
        android:id="@+id/middleText"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:text="some text"
        tools:targetApi="jelly_bean" />
</ScrollView>

<LinearLayout
    android:id="@+id/linearLayout">

... 

    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

更新

在此处输入图片说明

鲁本

设置android:scrollbars = "vertical"您的属性TextView还会松散不合适的textview周围的约束属性。在这里,我做了一些更改,使textview可滚动:

<?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">
    <ImageView
        android:id="@+id/imageView"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="40dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="8dp"
        app:layout_constraintBottom_toTopOf="@+id/title"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/title"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="32dp"
        android:layout_marginLeft="32dp"
        android:layout_marginTop="45dp"
        android:layout_marginEnd="32dp"
        android:layout_marginRight="32dp"
        android:gravity="center_horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView"
        tools:targetApi="jelly_bean" />

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="344dp"
        android:layout_height="50dp"
        android:layout_marginTop="32dp"
        android:orientation="vertical"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/title">

        <TextView
            android:id="@+id/middleText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scrollbars="vertical"
            android:text="some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text"
            tools:targetApi="jelly_bean" />
    </ScrollView>

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginTop="32dp"
        android:orientation="horizontal"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/scrollView"
        tools:ignore="MissingConstraints">


    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在其他两个视图之间插入视图

来自分类Dev

在首页上隐藏页眉和页脚,但在其他页面上显示

来自分类Dev

将一个面板停靠在其他两个面板之间

来自分类Dev

MySQL,在其他两个之间插入行

来自分类Dev

在其他类别之间共享两个实例

来自分类Dev

添加两个页眉和页脚,一个用于屏幕和打印

来自分类Dev

将UIView放在中心的两个视图之间?

来自分类Dev

将 ImageButton 放在两个视图组之间

来自分类Dev

页眉和页脚之间的视频

来自分类Dev

Android:在页眉和页脚之间居中滚动视图

来自分类Dev

如何在div“内容”周围放置两个div“页眉”和“页脚”

来自分类Dev

ScrollView在两个静态视图之间?

来自分类Dev

两个来源(视图)和其他模块如何并行交互

来自分类Dev

Python:检查一个元素是否在其他两个元素之间

来自分类Dev

如何确定一个点是否在其他两个点之间?

来自分类Dev

在其他系列的两个索引之间创建一个新的熊猫系列

来自分类Dev

一个点在其他两点之间的坐标,并知道起点和目标点的距离

来自分类Dev

限制UItableView的页眉和页脚的视图宽度

来自分类Dev

页眉和页脚之间的jQuery移动面板

来自分类Dev

使Div填充页眉和页脚之间的区域

来自分类Dev

页眉和页脚之间的垂直居中卡片

来自分类Dev

使Div填充页眉和页脚之间的区域

来自分类Dev

页眉和页脚中的可编辑文本区域需要在两个地方都显示更改

来自分类Dev

检查日期是否在其他两个日期之间或等于两个日期

来自分类Dev

检查日期是否在其他两个日期之间或等于两个日期

来自分类Dev

Scapy-在其他两个层之间插入数据包层

来自分类Dev

如何发现今天的日期是否在其他两个日期之间?

来自分类Dev

检测vector2是否在其他两个vector2之间

来自分类Dev

访问查询表达式:在其他两个单词之间提取单词

Related 相关文章

  1. 1

    在其他两个视图之间插入视图

  2. 2

    在首页上隐藏页眉和页脚,但在其他页面上显示

  3. 3

    将一个面板停靠在其他两个面板之间

  4. 4

    MySQL,在其他两个之间插入行

  5. 5

    在其他类别之间共享两个实例

  6. 6

    添加两个页眉和页脚,一个用于屏幕和打印

  7. 7

    将UIView放在中心的两个视图之间?

  8. 8

    将 ImageButton 放在两个视图组之间

  9. 9

    页眉和页脚之间的视频

  10. 10

    Android:在页眉和页脚之间居中滚动视图

  11. 11

    如何在div“内容”周围放置两个div“页眉”和“页脚”

  12. 12

    ScrollView在两个静态视图之间?

  13. 13

    两个来源(视图)和其他模块如何并行交互

  14. 14

    Python:检查一个元素是否在其他两个元素之间

  15. 15

    如何确定一个点是否在其他两个点之间?

  16. 16

    在其他系列的两个索引之间创建一个新的熊猫系列

  17. 17

    一个点在其他两点之间的坐标,并知道起点和目标点的距离

  18. 18

    限制UItableView的页眉和页脚的视图宽度

  19. 19

    页眉和页脚之间的jQuery移动面板

  20. 20

    使Div填充页眉和页脚之间的区域

  21. 21

    页眉和页脚之间的垂直居中卡片

  22. 22

    使Div填充页眉和页脚之间的区域

  23. 23

    页眉和页脚中的可编辑文本区域需要在两个地方都显示更改

  24. 24

    检查日期是否在其他两个日期之间或等于两个日期

  25. 25

    检查日期是否在其他两个日期之间或等于两个日期

  26. 26

    Scapy-在其他两个层之间插入数据包层

  27. 27

    如何发现今天的日期是否在其他两个日期之间?

  28. 28

    检测vector2是否在其他两个vector2之间

  29. 29

    访问查询表达式:在其他两个单词之间提取单词

热门标签

归档