Android 向上滚动时,布局高度应平行降低
我正在设计一个布局,在该行下方有一个recyclerView 布局,当我向上滚动时,行布局应该平行减少并固定在某个位置。第一个图像在滚动之前,第二个图像在滚动之后Android 向上滚动时,布局高度应平行降低,android,android-layout,listview,material-design,Android,Android Layout,Listview,Material Design,我正在设计一个布局,在该行下方有一个recyclerView 布局,当我向上滚动时,行布局应该平行减少并固定在某个位置。第一个图像在滚动之前,第二个图像在滚动之后 您可以使用这些很棒的库来完成您的工作 1-对于ListView 用于RecyclerView 回收者视图的实施 步骤1。将JitPack存储库添加到构建文件中 repositories { maven { url "https://jitpack.io" } } 步骤2。添加依赖项 depende
您可以使用这些很棒的库来完成您的工作 1-对于ListView 用于RecyclerView 回收者视图的实施 步骤1。将JitPack存储库添加到构建文件中
repositories {
maven {
url "https://jitpack.io"
}
}
步骤2。添加依赖项
dependencies {
compile 'com.github.kanytu:android-parallax-recyclerview:v1.7'
}
用法
(示例项目-)
- 创建对象列表并将其传递给视差回收器适配器的构造函数
List<String> myContent = new ArrayList<String>(); // or another object list ParallaxRecyclerAdapter<String> adapter = new ParallaxRecyclerAdapter<String>(content) { @Override public void onBindViewHolderImpl(RecyclerView.ViewHolder viewHolder, ParallaxRecyclerAdapter<String> adapter, int i) { // If you're using your custom handler (as you should of course) // you need to cast viewHolder to it. ((MyCustomViewHolder) viewHolder).textView.setText(myContent.get(i)); // your bind holder routine. } @Override public RecyclerView.ViewHolder onCreateViewHolderImpl(ViewGroup viewGroup, final ParallaxRecyclerAdapter<String> adapter, int i) { // Here is where you inflate your row and pass it to the constructor of your ViewHolder return new MyCustomViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.myRow, viewGroup, false)); } @Override public int getItemCountImpl(ParallaxRecyclerAdapter<String> adapter) { // return the content of your array return myContent.size(); } };`
// Event triggered when you click on a item of the adapter.
void onClick(View v, int position);
// Event triggered when the parallax is being scrolled.
void onParallaxScroll(float percentage, float offset, View parallax);
感谢您的回答,但我必须制作可点击的“同步”按钮。有监听器可用于点击回收器视图的视差标题
void onClick(视图v,int位置)代码>删除了我的否决票,谢谢你改进了答案。
// Event triggered when you click on a item of the adapter.
void onClick(View v, int position);
// Event triggered when the parallax is being scrolled.
void onParallaxScroll(float percentage, float offset, View parallax);