/**
- @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);
}
/**
- t 为目前滑动的高度
*/
@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;
}
}
MainActivity代码
package com.yqy.cmd;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import com.yqy.cmd.NotifyingScrollView.OnScrollChangedListener;
public class MainActivity extends Activity {
private ImageView topIv;
private NotifyingScrollView mySv;
private View view;
private LinearLayout myLl;
private int width;
private int height;
private int allowHeight;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
topIv = (ImageView) findViewById(R.id.topIv);
mySv = (NotifyingScrollView) findViewById(R.id.mySv);
view = findViewById(R.id.view);
myLl = (LinearLayout) findViewById(R.id.myLl);
//屏幕的宽高单位为px,所以我们在布局中需要转换为dp
width = ScreenUtils.getScreenWidth(this);
height = ScreenUtils.getScreenHeight(this);
allowHeight = Utils.px2dip(this, height) / 3;
topIv.setLayoutParams(new RelativeLayout.LayoutParams(
LayoutParams.MATCH_PARENT, Utils.px2dip(this, height) / 3));
view.setLayoutParams(new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, Utils.px2dip(this, height) / 3));
mySv.setOnScrollChangedListener(new OnScrollChangedListener() {
@Override
public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
if(t < allowHeight){
int height = allowHeight - t;
topIv.setLayoutParams(new RelativeLayout.LayoutParams(height*3, height));
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
activity_main布局
<RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:tools=“http://schemas.android.com/tools”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:background=“@android:color/holo_red_light”
tools:context=“.MainActivity”
tools:ignore=“NewApi” >
<ImageView
android:id=“@+id/topIv”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:background=“@drawable/ic_launcher” />
<com.yqy.cmd.NotifyingScrollView
android:id=“@+id/mySv”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:layout_alignParentLeft=“true”
android:layout_alignParentTop=“true” >
<LinearLayout
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:orientation=“vertical” >
<View
android:id=“@+id/view”
android:layout_width=“match_parent”
android:layout_height=“80dp” />
<LinearLayout
android:id=“@+id/myLl”
android:layout_width=“match_parent”
android:layout_height=“1000dp”
android:background=“@android:color/white”
android:orientation=“vertical” >
</com.yqy.cmd.NotifyingScrollView>
最后,面试前该准备哪些资源复习?
其实客户端开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。
这里再分享一下我面试期间的复习路线:(以下体系的复习资料是我从各路大佬收集整理好的)
《Android开发七大模块核心知识笔记》
《960全网最全Android开发笔记》
《379页Android开发面试宝典》
历时半年,我们整理了这份市面上最全面的安卓面试题解析大全
包含了腾讯、百度、小米、阿里、乐视、美团、58、猎豹、360、新浪、搜狐等一线互联网公司面试被问到的题目。熟悉本文中列出的知识点会大大增加通过前两轮技术面试的几率。
《507页Android开发相关源码解析》
只要是程序员,不管是Java还是Android,如果不去阅读源码,只看API文档,那就只是停留于皮毛,这对我们知识体系的建立和完备以及实战技术的提升都是不利的。
真正最能锻炼能力的便是直接去阅读源码,不仅限于阅读各大系统源码,还包括各种优秀的开源库。
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
就只是停留于皮毛,这对我们知识体系的建立和完备以及实战技术的提升都是不利的。
真正最能锻炼能力的便是直接去阅读源码,不仅限于阅读各大系统源码,还包括各种优秀的开源库。
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!