java - 如何在 ScrollView 中的图像上方添加 TextView ?

标签 java android scrollview

我需要在具有背景图像的 ScrollView 上方放置一个 TextView 。但我尝试放置 textView,它会移动到其他 sid 或不随滚动移动。

这是我的 xml。

    <ScrollView
        android:id="@+id/horizontalScrollView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >


        <LinearLayout
            android:gravity="top"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <ImageView
                android:id="@+id/imageViewObrazekGeometrie"
                android:layout_width="500dp"
                android:layout_height="777dp"
                android:paddingRight="120dp"
                android:src="@drawable/dataviewer" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="TextView" />

        </LinearLayout>
    </ScrollView>

最佳答案

我真的不明白你的问题,但会分享你哪里出错了。 ScrollView 只能容纳一个 subview ,但在您的情况下,您的 Horizo​​ntalScrollView 有两个 subview ,一个是 LinearLayout,另一个是 TextView,请将两者插入到一个父布局中。

关于java - 如何在 ScrollView 中的图像上方添加 TextView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57892362/

相关文章:

android - ScrollView上的setOnScrollChangeListener : Error

java - 在java中读取String中的字符?

java - 如何组织Spring项目

java - 使用 ASM 选择和修改 `if` 语句

android - 无法在android中居中布局

iphone - 从 UIScrollView + iphone 生成 PDF

java - token 未使用 FirebaseInstanceIdService 生成

java -//noinspection ForLoopReplaceableByForEach 是什么意思?

android - 如何控制位图的透明度?

android - 如何以编程方式更改 Android 标题栏文本颜色?