-
大小: 400KB文件类型: .zip金币: 1下载: 0 次发布日期: 2021-06-04
- 语言: 其他
- 标签: tablayout 顶部悬浮 AppBarLayout
资源简介
tablayout 悬浮与顶部效果,仿饿了么列表悬停效果,基于CoordinatorLayout 悬停,通过监听RecyclerView 滑动,是tablayout 悬浮 添加toolbar状态栏发生改变
代码片段和文件信息
package com.ss.myapplication;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shanshan on 2018/3/16.
*/
public class DemoAdapter extends RecyclerView.Adapter {
private List mDatas = new ArrayList<>();
private Context mContext;
private View mHeaderView;
private int ITEM_TYPE_NORMAL = 0;
private int ITEM_TYPE_HEADER = 1;
public DemoAdapter(Context context) {
mContext = context;
}
public void setDatas(List datas) {
mDatas = datas;
notifyDataSetChanged();
}
// 创建视图
@Override
public RecyclerView.ViewHolder
onCreateViewHolder(ViewGroup parent int viewType) {
if (viewType == ITEM_TYPE_HEADER) {
return new ViewHolder(mHeaderView);
} else {
View v = LayoutInflater.from(mContext).inflate(R.layout.item_common_text parent false);
return new ViewHolder(v);
}
}
@Override
public int getItemViewType(int position) {
if (null != mHeaderView && position == 0) {
return ITEM_TYPE_HEADER;
}
return ITEM_TYPE_NORMAL;
}
// 为Item绑定数据
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder int position) {
int type = getItemViewType(position);
if (type == ITEM_TYPE_HEADER) {
return;
}
int realPos = getRealItemPosition(position);
((ViewHolder) holder).mTextView.setText(mDatas.get(realPos));
}
private int getRealItemPosition(int position) {
if (null != mHeaderView) {
return position - 1;
}
return position;
}
@Override
public int getItemCount() {
int itemCount = mDatas.size();
if (null != mHeaderView) {
itemCount++;
}
return itemCount;
}
public void addHeaderView(View view) {
mHeaderView = view;
notifyItemInserted(0);
}
class ViewHolder extends RecyclerView.ViewHolder {
TextView mTextView;
ViewHolder(View v) {
super(v);
mTextView = (TextView) v.findViewById(R.id.textView);
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-03-30 10:40 MyApplication\
文件 127 2018-03-19 10:15 MyApplication\.gitignore
目录 0 2018-03-30 10:40 MyApplication\app\
文件 8 2018-03-19 10:15 MyApplication\app\.gitignore
文件 11082 2018-03-30 10:32 MyApplication\app\app.iml
文件 769 2018-03-19 10:24 MyApplication\app\build.gradle
目录 0 2018-03-19 10:15 MyApplication\app\libs\
文件 684 2018-03-19 10:15 MyApplication\app\proguard-rules.pro
目录 0 2018-03-30 10:40 MyApplication\app\src\
目录 0 2018-03-30 10:40 MyApplication\app\src\main\
文件 679 2018-03-19 10:25 MyApplication\app\src\main\AndroidManifest.xm
目录 0 2018-03-30 10:40 MyApplication\app\src\main\java\
目录 0 2018-03-30 10:40 MyApplication\app\src\main\java\com\
目录 0 2018-03-30 10:40 MyApplication\app\src\main\java\com\ss\
目录 0 2018-03-30 10:40 MyApplication\app\src\main\java\com\ss\myapplication\
文件 2533 2018-03-19 10:20 MyApplication\app\src\main\java\com\ss\myapplication\DemoAdapter.java
文件 3315 2018-03-19 10:27 MyApplication\app\src\main\java\com\ss\myapplication\DemoFragment.java
文件 2698 2018-03-30 10:33 MyApplication\app\src\main\java\com\ss\myapplication\MainActivity.java
目录 0 2018-03-30 10:40 MyApplication\app\src\main\java\com\ss\myapplication\tablayout\
文件 1689 2018-03-19 10:20 MyApplication\app\src\main\java\com\ss\myapplication\tablayout\AnimationUtils.java
文件 3064 2018-03-19 10:20 MyApplication\app\src\main\java\com\ss\myapplication\tablayout\DividerDrawable.java
文件 1018 2018-03-19 10:20 MyApplication\app\src\main\java\com\ss\myapplication\tablayout\TabItem.java
文件 675 2018-03-19 10:20 MyApplication\app\src\main\java\com\ss\myapplication\tablayout\ThemeUtils.java
文件 5386 2018-03-19 10:20 MyApplication\app\src\main\java\com\ss\myapplication\tablayout\ValueAnimatorCompat.java
文件 4586 2018-03-19 10:20 MyApplication\app\src\main\java\com\ss\myapplication\tablayout\ValueAnimatorCompatImplEclairMr1.java
文件 2663 2018-03-19 10:20 MyApplication\app\src\main\java\com\ss\myapplication\tablayout\ValueAnimatorCompatImplHoneycombMr1.java
文件 1542 2018-03-19 10:20 MyApplication\app\src\main\java\com\ss\myapplication\tablayout\ViewUtils.java
文件 372 2018-03-19 10:20 MyApplication\app\src\main\java\com\ss\myapplication\tablayout\ViewUtilsLollipop.java
文件 85106 2018-03-19 10:23 MyApplication\app\src\main\java\com\ss\myapplication\tablayout\XTabLayout.java
目录 0 2018-03-30 10:40 MyApplication\app\src\main\java\com\ss\myapplication\utils\
文件 1207 2018-03-30 10:32 MyApplication\app\src\main\java\com\ss\myapplication\utils\AppBarStateChangeListener.java
............此处省略31个文件信息
- 上一篇:自定义AutoTextView实现公告栏 3D 翻转动画
- 下一篇:淘淘商城参考资料
评论
共有 条评论