首页 > 解决方案 > 如何在 scollview 中的图像上方添加 textview?

问题描述

我需要在具有背景图像的滚动视图上方放置一个 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>

标签: javaandroidscrollview

解决方案


我真的不能正确理解你的问题,但会分享你哪里出错了。滚动视图只能容纳一个孩子,但在您的情况下,您的 Horizo​​ntalScrollView 有两个孩子,一个是 LinearLayout,另一个是 TextView,请将两者都插入到一个父布局中。


推荐阅读