繁体   English   中英

如何使用标题和FrameLayout滚动布局

[英]How to scroll layout with header and FrameLayout

我有一个视图,显示带有文本和徽标的标题,此布局的按钮显示详细信息。 当用户滚动此页面时,如何更改标题的高度?

我的布局:

    <?xml version="1.0" encoding="utf-8"?>
<ScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    xmlns:android="http://schemas.android.com/apk/res/android" >
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:gravity="right"
        android:id="@+id/rlBrand"
        android:background="@drawable/brand_back">
        <ImageView
            android:layout_marginRight="30dp"
            android:id="@+id/imgBrandLogoAct"
            android:layout_width="100dp"
            android:src="@drawable/ic_launcher"
            android:layout_centerVertical="true"
            android:layout_alignParentRight="true"
            android:layout_height="wrap_content" />
        <TextView
            android:id="@+id/txtBrandTitleAct"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="سامسونگ"
            style="@style/AudioFileInfoOverlayText"
            android:textStyle="bold"
            android:layout_marginRight="20dp"
            android:layout_toLeftOf="@+id/imgBrandLogoAct"
            android:textColor="@color/white"
            />
        </RelativeLayout>
    <FrameLayout android:layout_gravity="right" android:id="@+id/containerBrand" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_alignParentBottom="true" />
    </RelativeLayout>
</ScrollView>

我的布局

当用户滚动时我想要标题。

萨拉姆反射。 我认为这种方法对你有用。 使用scrollX和scrollY调整标题。

scrollView.getViewTreeObserver().addOnScrollChangedListener(new OnScrollChangedListener() {

    @Override
    public void onScrollChanged() {

        int scrollX = rootScrollView.getScrollX(); //for horizontalScrollView
        int scrollY = rootScrollView.getScrollY(); //for verticalScrollView
        //DO SOMETHING WITH THE SCROLL COORDINATES

    }
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM