滑动透明标题栏

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:background="@color/new_main_bg"
    android:layout_height="match_parent">
    <com.setbuy.activity.view.ViewPagerScroller
       android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="none">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </LinearLayout>
    </com.setbuy.activity.view.ViewPagerScroller>
    <LinearLayout
        android:id="@+id/ll_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:background="#FA5A3A"
        android:orientation="vertical" >

        <RelativeLayout
            android:id="@+id/catelayout"
            android:layout_width="match_parent"
            android:layout_height="60dip" >

            <ImageView
                android:id="@+id/iv_setting"
                android:layout_width="20dp"
                android:layout_height="fill_parent"
                android:layout_alignParentLeft="true"
                android:layout_marginLeft="12dp"
                android:layout_marginTop="15dp"
                android:src="@mipmap/per" />

            <TextView
                android:id="@+id/tv_title_bar_tb"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="25dp"
                android:gravity="center"
                android:text="我的"
                android:textColor="@color/white"
                android:textSize="16sp"
                android:textStyle="bold" />
        </RelativeLayout>
    </LinearLayout>
</RelativeLayout>

 

//头标题滑动
    public void initScroller(){
        ll_title.getBackground().mutate().setAlpha(0);

    }
    @Override
    public void onScroll(int scrollY) {
        if (scrollY < 10) {
            ll_title.getBackground().mutate().setAlpha(0);
        } else {
            ll_title.getBackground().mutate().setAlpha(255);
        }
    }

 

posted on 2018-03-29 14:21  爱学习的亮亮  阅读(137)  评论(0)    收藏  举报

导航