![](/img/trans.png)
[英]I need to scroll my Scroll view behind the relative layout( like overlay)
[英]how to make a scroll view to scroll over another layout with the layout behind staying intact but behind scroll content
如何使滚动视图滚动到另一个布局上,而后面的布局保持不变,但在滚动内容后面我的要求是应用程序的标题将保持固定,而如果其中的内容足够大可以滚动,则它下面的布局将滚动,请提供给我或建议任何解决此问题的方法
尝试这个:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:orientation="vertical">
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="100dp">
<LinearLayout
android:layout_width="269dp"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- any no. of views here -->
</Linearlayout>
<ScrollView>
</Linearlayout>
将此代码添加到 onCreate():
scrollView.getViewTreeObserver().addOnScrollChangedListener(new OnScrollChangedListener() {
@Override
public void onScrollChanged() {
Layout.setY(Layout.getY() + scrollView.getScrollY() - Layout.getY());
}
});
每次滚动视图时,布局都会移动相反的值。 看起来它根本不动。 确保您的所有视图都在 ScrollView 内。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.