android 根据滑动隐藏或显示导航 类似手机QQ好友个人信息
//重写ScrollViewpublic class NotifyingScrollView extends ScrollView {     /**     * @author Cyril Mottier     */    public interface OnScrollChangedListener {        void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt);    }    private OnScrollChangedListener mOnScrollChangedListener;    public NotifyingScrollView(Context context) {        super(context);    }    public NotifyingScrollView(Context context, AttributeSet attrs) {        super(context, attrs);    }    public NotifyingScrollView(Context context, AttributeSet attrs, int defStyle) {        super(context, attrs, defStyle);    }    @Override    protected void onScrollChanged(int l, int t, int oldl, int oldt) {        super.onScrollChanged(l, t, oldl, oldt);        if (mOnScrollChangedListener != null) {            mOnScrollChangedListener.onScrollChanged(this, l, t, oldl, oldt);        }    }    public void setOnScrollChangedListener(OnScrollChangedListener listener) {        mOnScrollChangedListener = listener;    }}
View Code

布局引用重写NotifyingScrollView控件

android 根据滑动隐藏或显示导航 类似手机QQ好友个人信息
 <你的项目路径.NotifyingScrollView            android:id="@id/sv_personal"            android:layout_width="match_parent"            android:layout_height="match_parent"            android:background="@color/layout_bg"            android:scrollbars="none" >     <LinearLayout                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:background="@color/layout_bg"                android:orientation="vertical" >你要显示的内容</LinearLayout>        </你的项目路径.NotifyingScrollView>
View Code

activity使用引用

android 根据滑动隐藏或显示导航 类似手机QQ好友个人信息
NotifyingScrollView sv_personal=(NotifyingScrollView)findViewById(R.id.sv_personal);sv_personal.setOnScrollChangedListener(mOnScrollChangedListener);private NotifyingScrollView.OnScrollChangedListener mOnScrollChangedListener = new NotifyingScrollView.OnScrollChangedListener() {public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {int Height=Utility.dip2px(context, 130);float ratio =Math.max(Math.min(1, t/Height), 0);//导航控件linar_top.setAlpha(ratio* 255);}};
View Code

int Height=Utility.dip2px(context, 130); 130为要滑动的高度

更多相关文章

  1. Android:设置手机返回键是否可返回
  2. Android如何判断手机里是否安装了某个应用
  3. Android 获取手机型号、信号强度、厂商等信息
  4. Android 监听短信内容变化,并发送到自己的手机
  5. Android 手机获取当前IP
  6. android中选择文件,部分手机找不到文件路径问题的解决
  7. android 如何得到手机的信息..
  8. Android 系统设置 之 保持手机屏幕常亮的方法
  9. android实现手机传感器调用

随机推荐

  1. Fetching https://dl-ssl.google.com/and
  2. 登录案例_android
  3. Android统计图集合源码
  4. 另类方法屏蔽Android4.03的HOME按键
  5. android柱状图源码
  6. ANDROID应用安全防御
  7. AndroidUI线程机制
  8. Android O 版本(Android 8.0) 存储空间不足
  9. 明天 你看好Erlang还是看好android
  10. TableLayout设置行与行之间的分割线