我需要在具有背景图像的 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 ,但在您的情况下,您的 HorizontalScrollView 有两个 subview ,一个是 LinearLayout,另一个是 TextView,请将两者插入到一个父布局中。
关于java - 如何在 ScrollView 中的图像上方添加 TextView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57892362/