我的编程空间,编程开发者的网络收藏夹
学习永远不晚

如何使用Android实现上拉吸顶效果

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

如何使用Android实现上拉吸顶效果

这篇文章给大家分享的是有关如何使用Android实现上拉吸顶效果的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

具体内容如下

效果图

如何使用Android实现上拉吸顶效果

1.home_layout.xml

此布局即可实现上拉固定在顶部

<?xml version="1.0" encoding="UTF-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:rvp="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    xmlns:tl="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:id="@+id/ll_base"    android:background="@drawable/bg_f8f8f8"    >    <!-- <android.support.v4.widget.SwipeRefreshLayout        android:layout_width="match_parent"        android:layout_height="wrap_content">-->      <!--中间内容-->        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:orientation="vertical"            >             <FrameLayout                android:focusableInTouchMode="true"                android:focusable="true"                android:layout_width="match_parent"                android:visibility="gone"                android:layout_height="205dp">                 <com.broker.liming.banner.view.BannerBgContainer                    android:id="@+id/banner_bg_container"                    android:layout_width="match_parent"                    android:layout_height="205dp" />                 <com.broker.liming.banner.LoopLayout                    android:id="@+id/loop_layout"                    android:layout_width="match_parent"                    android:layout_height="120dp"                    android:layout_gravity="bottom"                    android:layout_marginTop="@dimen/lay_85" />            </FrameLayout>            <android.support.design.widget.CoordinatorLayout                android:id="@+id/main_content"                android:layout_width="match_parent"                android:layout_height="wrap_content">                 <android.support.design.widget.AppBarLayout                    android:id="@+id/appbar"                    android:layout_width="match_parent"                    android:layout_height="wrap_content"                    app:elevation="0dp"                    app:layout_behavior="com.broker.liming.widget.AppBarLayoutBehavior"                     >                     <android.support.design.widget.CollapsingToolbarLayout                        android:id="@+id/main.collapsing"                        android:layout_width="match_parent"                        android:layout_height="wrap_content"                        app:layout_scrollFlags="scroll|exitUntilCollapsed">                       <!-- android:fitsSystemWindows="true"                        app:contentScrim="?attr/colorPrimary"                        app:expandedTitleMarginEnd="64dp"                        app:expandedTitleMarginStart="48dp"-->                      <!--  <android.support.constraint.ConstraintLayout                            android:layout_width="match_parent"                            android:layout_height="match_parent"                            android:fitsSystemWindows="true"                            android:scaleType="centerCrop"                            app:layout_collapseMode="parallax">-->                            <RelativeLayout                                android:layout_width="match_parent"                                android:layout_height="wrap_content"                                android:orientation="vertical"                                android:background="@drawable/bg_f8f8f8"                                >                                <!--app:layout_constraintTop_toTopOf="parent"                                app:layout_constraintLeft_toLeftOf="parent"                                app:layout_constraintRight_toRightOf="parent"                                app:layout_constraintBottom_toBottomOf="parent"-->                                <com.jcodecraeer.xrecyclerview.XRecyclerView                                    android:id="@+id/xrv_product"                                                                        android:nestedScrollingEnabled="false"                                    android:scrollbars="none"                                    android:visibility="visible"                                     />                                <android.support.v7.widget.RecyclerView                                    android:id="@+id/recycler"                                    android:layout_width="match_parent"                                    android:layout_height="wrap_content"                                    android:visibility="gone"                                    android:overScrollMode="never" />                                <!--<com.yi.haigou.shop.view.ShopInfoView                                    android:id="@+id/shop_inof_view"                                    android:layout_width="match_parent"                                    android:layout_height="wrap_content"                                    app:layout_constraintTop_toTopOf="parent" />                                <com.yi.haigou.shop.view.ShopAddressView                                    android:id="@+id/shop_address_view"                                    android:layout_width="match_parent"                                    android:layout_height="wrap_content"                                    app:layout_constraintBottom_toBottomOf="parent"                                    app:layout_constraintTop_toTopOf="parent" />-->                            </RelativeLayout>                       <!--  </android.support.constraint.ConstraintLayout>-->                        <android.support.v7.widget.Toolbar                            android:id="@+id/toolbar"                            android:layout_width="match_parent"                            android:layout_height="@dimen/lay_60"                            >                             <!--<android.support.constraint.ConstraintLayout-->                            <!--android:layout_width="match_parent"-->                            <!--android:layout_height="match_parent">-->                            <!--<com.yi.shop.shop.view.ShopSearchBar-->                            <!--android:id="@+id/search_bar_view"-->                            <!--android:layout_width="match_parent"-->                            <!--android:layout_height="wrap_content"-->                            <!--android:background="@drawable/ic_shop_title"-->                            <!--app:layout_constraintTop_toTopOf="parent"/>-->                            <!--</android.support.constraint.ConstraintLayout>-->                        </android.support.v7.widget.Toolbar>                      </android.support.design.widget.CollapsingToolbarLayout>                 </android.support.design.widget.AppBarLayout>              <!--吸顶tab-->                <LinearLayout                    android:id="@+id/ll_tab"                    android:layout_width="match_parent"                    android:layout_height="match_parent"                    android:orientation="vertical"                    android:visibility="gone"                    app:layout_behavior="@string/appbar_scrolling_view_behavior">                     <com.broker.liming.widget.SlidingTabLayout                        android:id="@+id/tl_9"                        android:layout_width="match_parent"                        android:layout_height="@dimen/lay_45"                        android:paddingLeft="12dp"                        android:paddingRight="12dp"                        android:layout_marginTop="@dimen/lay_20"                        tl:tl_indicator_anim_duration="100"                        tl:tl_indicator_anim_enable="true"                        tl:tl_indicator_bounce_enable="false"                        tl:tl_indicator_color="@color/name_1A75FF"                        tl:tl_indicator_margin_left="2dp"                        tl:tl_indicator_margin_right="2dp"                        tl:tl_indicator_                        tl:tl_textSelectColor="@color/white"                        tl:tl_textUnselectColor="@color/text_000000"                        tl:tl_textsize="@dimen/font_13"                        />                    <android.support.v4.view.ViewPager                        android:id="@+id/viewpager"                        android:layout_width="match_parent"                        android:layout_height="match_parent"                        android:layout_marginTop="@dimen/lay_12"                        />                    <!--公司信息-->                    <LinearLayout                        android:layout_width="match_parent"                        android:layout_height="wrap_content"                        android:orientation="vertical"                        android:layout_alignParentBottom="true"                        android:visibility="gone"                        >                          <TextView                            android:id="@+id/tv_phone"                            android:layout_width="match_parent"                            android:layout_height="wrap_content"                            android:layout_marginLeft="@dimen/lay_12"                            android:layout_marginRight="@dimen/lay_12"                            android:layout_marginTop="@dimen/lay_34"                            android:gravity="center"                            android:text="1569796696"                            android:textColor="@color/color_c7c7c7"                            android:textSize="@dimen/font_13" />                         <LinearLayout                            android:layout_width="match_parent"                            android:layout_height="wrap_content"                            android:layout_marginBottom="@dimen/font_16"                            android:layout_marginLeft="@dimen/lay_12"                            android:layout_marginRight="@dimen/lay_12"                            android:layout_marginTop="@dimen/lay_12"                            android:gravity="center">                             <TextView                                android:id="@+id/tv_email"                                android:layout_width="wrap_content"                                android:layout_height="wrap_content"                                android:textColor="@color/color_c7c7c7"                                android:textSize="@dimen/font_13" />                             <ImageView                                android:id="@+id/iv_copy"                                android:layout_width="wrap_content"                                android:layout_height="wrap_content"                                android:layout_marginLeft="@dimen/lay_6"                                android:background="@mipmap/home_copy" />                        </LinearLayout>                    </LinearLayout>                </LinearLayout>             </android.support.design.widget.CoordinatorLayout>          </LinearLayout>  <!--  </android.support.v4.widget.SwipeRefreshLayout>-->      <!--搜索-->    <RelativeLayout        android:id="@+id/rl_top"        android:layout_width="match_parent"        android:layout_height="@dimen/lay_70"        android:background="@color/transparent"        android:gravity="bottom">         <RelativeLayout            android:id="@+id/rl_title"            android:layout_width="match_parent"            android:layout_height="@dimen/lay_45"            android:gravity="center_vertical"            android:paddingLeft="@dimen/lay_12">             <TextView                android:id="@+id/tv_title"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_centerVertical="true"                android:layout_marginRight="@dimen/lay_12"                android:text="日月保盒"                android:textColor="@color/white"                android:textSize="@dimen/font_18"                android:textStyle="bold" />             <LinearLayout                android:id="@+id/ll_search"                android:layout_width="match_parent"                android:layout_height="@dimen/lay_31"                android:layout_centerVertical="true"                android:layout_marginRight="@dimen/lay_57"                android:layout_toRightOf="@+id/tv_title"                android:background="@drawable/shape_search_product"                android:gravity="center_vertical">                 <ImageView                    android:id="@+id/iv_search"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:layout_centerVertical="true"                    android:layout_marginLeft="@dimen/lay_12"                    android:layout_marginRight="@dimen/lay_5"                    android:background="@mipmap/home_search" />                 <TextView                    android:id="@+id/tv_search"                    android:layout_width="0dp"                    android:layout_height="wrap_content"                    android:layout_weight="1"                    android:ellipsize="end"                    android:paddingRight="@dimen/lay_12"                    android:singleLine="true"                    android:text=""                    android:textColor="@color/color_c7c7c7"                    android:textSize="@dimen/lay_14" />            </LinearLayout>             <RelativeLayout                android:id="@+id/rl_msg"                android:layout_width="wrap_content"                android:layout_height="match_parent"                android:layout_alignParentRight="true"                android:layout_marginEnd="@dimen/lay_12"                android:gravity="center_vertical">                 <ImageView                    android:id="@+id/iv_msg"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:layout_marginTop="@dimen/lay_5"                    android:background="@mipmap/home_message_white" />                 <TextView                    android:id="@+id/tv_msgnum"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:layout_marginStart="11dp"                    android:layout_marginTop="@dimen/lay_2"                    android:background="@drawable/yuandianred"                    android:gravity="center"                    android:minWidth="14dp"                    android:paddingLeft="3dp"                    android:paddingRight="3dp"                    android:singleLine="true"                    android:textColor="@android:color/white"                    android:textSize="@dimen/font_10"                    android:visibility="visible" />            </RelativeLayout>         </RelativeLayout>     </RelativeLayout>     </RelativeLayout>

2.fragment

package com.broker.liming.fragment; import android.Manifest;import android.app.Activity;import android.content.ClipData;import android.content.ClipboardManager;import android.content.Context;import android.content.Intent;import android.content.pm.PackageInfo;import android.content.pm.PackageManager;import android.content.res.Configuration;import android.content.res.Resources;import android.graphics.Color;import android.graphics.Point;import android.graphics.drawable.ColorDrawable;import android.os.Build;import android.os.Bundle;import android.os.Handler;import android.support.annotation.NonNull;import android.support.design.widget.AppBarLayout;import android.support.design.widget.CoordinatorLayout;import android.support.v4.app.ActivityCompat;import android.support.v4.app.Fragment;import android.support.v4.app.FragmentManager;import android.support.v4.app.FragmentPagerAdapter;import android.support.v4.app.FragmentTransaction;import android.support.v4.content.ContextCompat;import android.support.v4.view.ViewPager;import android.support.v7.widget.LinearLayoutManager;import android.support.v7.widget.RecyclerView;import android.support.v7.widget.Toolbar;import android.text.Html;import android.text.TextUtils;import android.util.DisplayMetrics;import android.util.Log;import android.util.TypedValue;import android.view.Display;import android.view.Gravity;import android.view.MotionEvent;import android.view.View;import android.view.ViewGroup;import android.view.Window;import android.view.WindowManager;import android.widget.Button;import android.widget.EditText;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.PopupWindow;import android.widget.RelativeLayout;import android.widget.TextView;import android.widget.Toast; import com.bigkoo.convenientbanner.ConvenientBanner;import com.bigkoo.convenientbanner.holder.CBViewHolderCreator;import com.bigkoo.convenientbanner.listener.OnItemClickListener;import com.broker.liming.R;import com.broker.liming.activity.AgreementActivity;import com.broker.liming.activity.SplashActivity;import com.broker.liming.activity.WebViewActivity;import com.broker.liming.adapter.ArticleAdapter;import com.broker.liming.adapter.HomeAdapter;import com.broker.liming.api.HttpParams;import com.broker.liming.api.WebHttpParams;import com.broker.liming.application.LoadBugClass;import com.broker.liming.banner.IndicatorLocation;import com.broker.liming.banner.LoopLayout;import com.broker.liming.banner.LoopStyle;import com.broker.liming.banner.OnDefaultImageViewLoader;import com.broker.liming.banner.bean.BannerInfo;import com.broker.liming.banner.listener.OnBannerItemClickListener;import com.broker.liming.banner.view.BannerBgContainer;import com.broker.liming.base.BaseFragment;import com.broker.liming.bean.ColorInfo;import com.broker.liming.bean.CompanyBaseBean;import com.broker.liming.bean.HeadHomeBean;import com.broker.liming.bean.HomeBannerBean;import com.broker.liming.bean.HomeBean;import com.broker.liming.bean.HomeProductBean;import com.broker.liming.bean.MineBean;import com.broker.liming.bean.RecommendListBean;import com.broker.liming.bean.SettingBean;import com.broker.liming.bean.UserBean;import com.broker.liming.bean.UserInfoBean;import com.broker.liming.college.bean.ArticleClassifyListBean;import com.broker.liming.college.bean.FaXianListsBean;import com.broker.liming.college.bean.FindClassifysBean;import com.broker.liming.college.bean.KaoShiStatussBean;import com.broker.liming.constant.Constants;import com.broker.liming.dao.UserBeanDao;import com.broker.liming.editview.FunctionItem;import com.broker.liming.editview.SFUtils;import com.broker.liming.event.ChangXianLogin;import com.broker.liming.event.ELoginSuccess;import com.broker.liming.event.EventManager;import com.broker.liming.event.LongRiskEvent;import com.broker.liming.event.RefreshHomeArticleEvent;import com.broker.liming.interf.OnBottomTabReselectListener;import com.broker.liming.interfaclisetener.ArticleHomeClickLisener;import com.broker.liming.utils.AccountUtils;import com.broker.liming.utils.CommonUtils;import com.broker.liming.utils.DensityUtil;import com.broker.liming.utils.GsonUtils;import com.broker.liming.utils.LogUtil;import com.broker.liming.utils.LogUtil2;import com.broker.liming.utils.SPUtils;import com.broker.liming.utils.SobotUtils;import com.broker.liming.utils.StatusBarUtil;import com.broker.liming.utils.StringUtil;import com.broker.liming.utils.ToastUtil;import com.broker.liming.utils.UIHelper;import com.broker.liming.utils.Utils;import com.broker.liming.utils.ViewFindUtils;import com.broker.liming.viewholder.NetworkImageHolderView;import com.broker.liming.viewholder.TabViewHolder;import com.broker.liming.widget.AppBarStateChangeListener;import com.broker.liming.widget.CustomDialog;import com.broker.liming.widget.MyScrollView;import com.broker.liming.widget.OnTabSelectListener;import com.broker.liming.widget.RecyclerviewScrollLisetener;import com.broker.liming.widget.SetOnclickInterface;import com.broker.liming.widget.SlidingTabLayout;import com.broker.liming.widget.TitleBar;import com.bumptech.glide.Glide;import com.bumptech.glide.load.engine.DiskCacheStrategy;import com.bumptech.glide.load.resource.bitmap.CenterCrop;import com.bumptech.glide.load.resource.bitmap.RoundedCorners;import com.bumptech.glide.request.RequestOptions;import com.google.gson.Gson;import com.google.gson.JsonArray;import com.google.gson.JsonElement;import com.google.gson.JsonParser;import com.jcodecraeer.xrecyclerview.ProgressStyle;import com.jcodecraeer.xrecyclerview.XRecyclerView;import com.scwang.smartrefresh.layout.SmartRefreshLayout; import org.greenrobot.eventbus.Subscribe;import org.greenrobot.eventbus.ThreadMode;import org.json.JSONException; import java.util.ArrayList;import java.util.List;import java.util.Random; import lecho.lib.hellocharts.model.Line; import static com.broker.liming.constant.Constants.flag;import static com.broker.liming.utils.SystemInfoUtils.getScreenWidth;import static com.umeng.socialize.utils.ContextUtil.getPackageName; public class HomeFragment extends BaseFragment implements OnBottomTabReselectListener, OnItemClickListener, XRecyclerView.LoadingListener, OnBannerItemClickListener, RecyclerviewScrollLisetener,ArticleHomeClickLisener {    public static ConvenientBanner mConvenientBanner;    private List<HomeBannerBean> mHomePagePlatAdList;    private HomeAdapter mHomeAdapter;    private XRecyclerView mXrvProduct;    private SmartRefreshLayout refreshLayout;    private XRecyclerView xRecyclerView;    private ImageView iv_center;    private RelativeLayout rl_wallet;    private RelativeLayout rl_msg;    private TextView tv_msgnum;    private HomeBean.PopUpEntity popUp;    private TitleBar mTitleBar;    private TextView tv_statusBar_slide;     private BannerBgContainer container;    private LoopLayout loopLayout;    private int imageHeight;    private RelativeLayout rl_title;    private String longRiskUrl;    private String longCenterUrl;    private String longCenterUrl2;    private String longCenterNew;//新版     private String longCenterUrl3;    public static boolean canClick;    public static boolean canClick2;    private RelativeLayout rl_top;    private ImageView iv_search;    private String customerLevel;    public static String flag3;    public static String certifiedState;    public static String flag2;    private ImageView iv_contact;    private int duration;    public static boolean canClick3;    //    private MoveImage iv_contact2;    private TextView tv_245;    private TextView tv_247;    private TextView tv_chang_commit;    private EditText edit_logoin;    private EditText edit_screen;    private EditText edit_riyuebaohe;    private TextView tv_tinker;    private TextView tv_title;    private LinearLayout ll_search;    private ImageView iv_msg;    private int position;    private TextView tv_search;     private ImageView ivBannerHeadBg;    private int count;    private boolean isInit = true;    private List<String> bannerList = new ArrayList<>();    private List<ColorInfo> colorList = new ArrayList<>();    private int mDistanceY;    private LinearLayoutManager layoutManager;    private int y;    private int height;    private String localVersion;    private String key;    private PopupWindow popWindow;    private boolean hidden2 = false;    private SFUtils sfUtils;    private List<FunctionItem> allData;    private List<FunctionItem> selData;    private ImageView iv_back_top;    private String localVersionLoad;    private RecyclerView recycler;    private  ViewPager viewpager;    private SlidingTabLayout tl_9;    private Toolbar toolbar;    private List<String> mTitles=new ArrayList<>();    private ArrayList<Fragment> mFragments = new ArrayList<>();    //    private MyPagerAdapter mAdapter;    private FragmentManager fragmentManager;    private View pagerview;    private SlidingTabLayout tab_head;    private MyScrollView scrollowview;    private int[] location2;    private int[] location3;    private int yrecycler;    private TextView tv_phone;    private TextView tv_email;    private ImageView iv_copy;    private AppBarLayout appbar;    private CoordinatorLayout main_content;    private CustomDialog dialog;    private boolean isFirstLay = true;    private List<ArticleClassifyListBean> articleClassifyList;    private LinearLayout ll_tab;    private RelativeLayout ll_base;    public static SettingBean settingBean;    private CompanyBaseBean companyBaseBean;    private MyPagerAdapter mAdapter;    private boolean isRemind=false;//点文章不会到顶部其余都回到顶部    private boolean isSame=true;//是否有不同tab 判断后台增加或者减少tab刷新 否者不刷新tab方便记录点击位置    private boolean isFirstTab=true;//是否第一进入加载 第一次进入app时刷新tab 不是第一次需判断后台增加或者减少tab刷新 否者不刷新tab方便记录点击位置    private boolean isHoutai=false;    private int appbarState;    private boolean isOther=false;    private boolean isRemindTrue=false;      @Override    protected int getContentView() {        // 加载系统默认设置,字体不随用户设置变化        Resources res = mContext.getResources();        Configuration config = new Configuration();        config.setToDefaults();        res.updateConfiguration(config, res.getDisplayMetrics());         return R.layout.home_fragment_two;    }     @Override    protected void initTitleBar(View view) {//        mTitleBar = (TitleBar) view.findViewById(R.id.title_bar);//        mTitleBar.setTitle("");//        setStateBar();//        mTitleBar.setTitleBarBg(android.R.color.transparent);                   iv_search = (ImageView) view.findViewById(R.id.iv_search); //        rl_wallet = (RelativeLayout) view.findViewById(R.id.rl_wallet);//        rl_wallet.setOnClickListener(new View.OnClickListener() {//            @Override//            public void onClick(View view) {//                if (!isLogin()) {//                    UIHelper.showLogin(mContext);//                    return;//                }////                UserBean query = UserBeanDao.query();//                if (AccountUtils.isAuthentication(query.certifiedState)) {//                    UIHelper.showMyWallet(mContext);//                } else {//                    UIHelper.showWebView(mContext, WebHttpParams.showCredentials());//                }//            }//        });        rl_msg = (RelativeLayout) view.findViewById(R.id.rl_msg);        rl_msg.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                if (!isLogin()) {                    UIHelper.showLogin(mContext);                    return;                }                UIHelper.showWebView2(mContext, WebHttpParams.showMyNews());            }        });        tv_msgnum = (TextView) view.findViewById(R.id.tv_msgnum); //        iv_center = (ImageView) view.findViewById(R.id.iv_center);         //        iv_center.setVisibility(View.VISIBLE);//        Animation anim =new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);//        anim.setFillAfter(true); // 设置保持动画最后的状态//        anim.setDuration(10000); // 设置动画时间//        anim.setInterpolator(new LinearInterpolator()); // 设置插入器(线性匀速)//        mTitleBar.startAnimation(anim);    }       @Override    public void initView(View view) {//        setFullScreen();//        changeStatusBarTextColor(true);//        BarUtils.setColorNoTranslucent(getActivity(), getResources().getColor(R.color.transparent));//        BarUtils.setRootViewFitsSystemWindows(getActivity(), false);//        //此方法上下状态栏都透明,状态栏字体颜色为黑色//        BarUtils.setTranslucentForCoordinatorLayout(getActivity(),0);        pagerview = view;        StatusBarUtil.setTranslucentStatus(getActivity());        StatusBarUtil.setStatusBarDarkTheme(getActivity(), false);         if (!EventManager.isRegistered(this)) {            EventManager.register(this);        }        tv_tinker = (TextView) view.findViewById(R.id.tv_tinker);        tv_245 = (TextView) view.findViewById(R.id.tv_245);        tv_247 = (TextView) view.findViewById(R.id.tv_247);        tv_chang_commit = (TextView) view.findViewById(R.id.tv_chang_commit);        edit_logoin = (EditText) view.findViewById(R.id.edit_logoin);        edit_screen = (EditText) view.findViewById(R.id.edit_screen);        edit_riyuebaohe = (EditText) view.findViewById(R.id.edit_riyuebaohe);        tv_title = (TextView) view.findViewById(R.id.tv_title);        ll_search = (LinearLayout) view.findViewById(R.id.ll_search);        iv_msg = (ImageView) view.findViewById(R.id.iv_msg);        rl_top = (RelativeLayout) view.findViewById(R.id.rl_top);        iv_contact = (ImageView) view.findViewById(R.id.iv_contact);        tv_search = (TextView) view.findViewById(R.id.tv_search);        iv_back_top = (ImageView) view.findViewById(R.id.iv_back_top);        recycler = (RecyclerView) view.findViewById(R.id.recycler);//        refreshLayout = (SmartRefreshLayout) view.findViewById(R.id.refreshLayout);        viewpager = (ViewPager) view.findViewById(R.id.viewpager);        tl_9 = (SlidingTabLayout) view.findViewById(R.id.tl_9);        toolbar = (Toolbar) view.findViewById(R.id.toolbar);        appbar = (AppBarLayout) view.findViewById(R.id.appbar);//        tab_head=(SlidingTabLayout)view.findViewById(R.id.tab_head);//        scrollowview=(MyScrollView) view.findViewById(R.id.scrollowview);         tv_phone = (TextView) view.findViewById(R.id.tv_phone);        tv_email = (TextView) view.findViewById(R.id.tv_email);        iv_copy = (ImageView) view.findViewById(R.id.iv_copy);        main_content = (CoordinatorLayout) view.findViewById(R.id.main_content);        ll_tab = (LinearLayout) view.findViewById(R.id.ll_tab);        ll_base = (RelativeLayout) view.findViewById(R.id.ll_base);        edit_riyuebaohe.setText(flag + "");        tv_title.setTextColor(mContext.getResources().getColor(R.color.white));        ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.yuanjiao24whire));        iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_white));        rl_top.setBackgroundColor(Color.argb((int) 0, 255, 255, 255));//AGB由相关工具获得,或者美工提供        ArticleHomeFragment.setScrollListener(this);        ArticleHomeFragment.setArticleListener(this);        Constants.isHoutai=false;         mAdapter = new MyPagerAdapter(getActivity().getSupportFragmentManager());         mXrvProduct = (XRecyclerView) view.findViewById(R.id.xrv_product);        mXrvProduct.setLoadingMoreEnabled(false);         mXrvProduct.setPullRefreshEnabled(true);        mXrvProduct.setLoadingListener(this);        mXrvProduct.setArrowImageView(R.mipmap.iconfont_downgrey);        mXrvProduct.setRefreshProgressStyle(ProgressStyle.SysProgress);        mXrvProduct.setNestedScrollingEnabled(true);         final View headerView = mInflater.inflate(R.layout.fragment_home_banner, (ViewGroup) view.findViewById(android.R.id.content), false);        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);        layoutParams.gravity = Gravity.CENTER_HORIZONTAL;        headerView.setLayoutParams(layoutParams);         container = (BannerBgContainer) headerView.findViewById(R.id.banner_bg_container);        loopLayout = (LoopLayout) headerView.findViewById(R.id.loop_layout);        //状态栏高度        int statusBarHeight = 0;        int resourceId = getResources().getIdentifier("status_bar_height", "dimen",                "android");        if (resourceId > 0) {            statusBarHeight = getResources().getDimensionPixelSize(resourceId);        }        //屏幕高度        DisplayMetrics dm = mContext.getApplicationContext().getResources().getDisplayMetrics();         final float scale = dm.density;        int i = (int) (54 * scale + 0.5f) + DensityUtil.dp2px(100); //        //获取当前控件的布局对象        ViewGroup.LayoutParams params = (ViewGroup.LayoutParams) container.getLayoutParams();        params.width = getScreenWidth();//设置当前控件布局的宽度        params.height = getScreenWidth() * 1 / 2;//设置当前控件布局的高度        container.setLayoutParams(params);//将设置好的布局参数应用到控件中         layoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);         mXrvProduct.setLayoutManager(layoutManager);        mXrvProduct.addHeaderView(headerView);        mHomeAdapter = new HomeAdapter(mContext, getActivity().getSupportFragmentManager(), getActivity(), dm.heightPixels - statusBarHeight - i + DensityUtil.dip2px(mContext, 50));        mXrvProduct.setAdapter(mHomeAdapter);          // 设置轮播图属性        loopLayout.setLoop_ms(4000);//轮播的速度(毫秒)        loopLayout.setLoop_duration(400);//滑动的速率(毫秒)        loopLayout.setScaleAnimation(false);// 设置是否需要动画        loopLayout.setLoop_style(LoopStyle.Empty);//轮播的样式-默认empty        loopLayout.setIndicatorLocation(IndicatorLocation.Center);//指示器位置-中Center        loopLayout.initializeData(mContext);          // 设置监听        loopLayout.setOnLoadImageViewListener(new OnDefaultImageViewLoader() {            @Override            public void onLoadImageView(ImageView view, Object object, int point) {                              Glide.with(mContext)                        .load(object)                        .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(DensityUtil.dp2px(12))))                        .into(view);                 LogUtil2.log("position--" + point + "");             }         });         loopLayout.setOnBannerItemClickListener(this);         setScroll();          RequestOptions options = new RequestOptions().diskCacheStrategy(DiskCacheStrategy.RESOURCE);//只缓存最终的图片        //!isDestroy(getActivity()        if (getActivity() != null) {            Glide.with(getActivity()).load(R.mipmap.jingzhi).apply(options).into(iv_contact);        }         iv_contact.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                 if (!AccountUtils.isLogin()) {                    UIHelper.showLogin(mContext);                    return;                }                 SobotUtils.startSobot(getActivity());            }        });        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {            RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) rl_top.getLayoutParams();            layoutParams2.height = dip2px(getActivity(), 80);            rl_top.setLayoutParams(layoutParams2);         } else {            RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) rl_top.getLayoutParams();            layoutParams2.height = dip2px(getActivity(), 70);            rl_top.setLayoutParams(layoutParams2);        }          imageHeight = dip2px(getActivity(), 200);        rl_title = (RelativeLayout) view.findViewById(R.id.rl_title);        initListeners();     }     public void setScroll() {         main_content.setOnTouchListener(new View.OnTouchListener() {            @Override            public boolean onTouch(View v, MotionEvent event) {                switch (event.getAction()) {                    case MotionEvent.ACTION_DOWN:                        Log.i("滚动高度--tt", "按下");                        if (getActivity() != null) {                            Glide.with(getActivity()).load(R.mipmap.huadong2).into(iv_contact);                            new Handler().postDelayed(new Runnable() {                                @Override                                public void run() {                                    Glide.with(getActivity()).load(R.mipmap.jingzhi).into(iv_contact);                                }                            }, 1500);                        }                        break;                    case MotionEvent.ACTION_MOVE:                        Log.i("滚动高度--tt", "移动");                        if (getActivity() != null) {                            Glide.with(getActivity()).load(R.mipmap.huadong).into(iv_contact);                        }                        break;                    case MotionEvent.ACTION_UP:                        Log.i("滚动高度--tt", "抬起");                        break;                }                return false;            }        });        appbar.addOnOffsetChangedListener(new AppBarStateChangeListener() {            @Override            public void onStateChanged(AppBarLayout appBarLayout, State state) {                 if (state == State.EXPANDED) {                     Log.i("滚动高度--", "展开");                  } else if (state == State.COLLAPSED) {                     Log.i("滚动高度--", "折叠");                     setpopLoad();                } else {                      Log.i("滚动高度--", "中间");                 }            }        });        appbar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {            @Override            public void onOffsetChanged(AppBarLayout appBarLayout, int i) {                height = dip2px(mContext, 170);                y = Math.abs(i);                int alpha = 255 * y / (height);                if (alpha > 255) {                    alpha = 255;                }                if (alpha < 5) {                    alpha = 0;                }                 LogUtil2.log("滑动高度--off" + y + "--" + height + "--");                if (y <= height) {                    tv_title.setTextColor(mContext.getResources().getColor(R.color.white));                    ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.yuanjiao24whire));                    iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_white));                    rl_top.setBackgroundColor(Color.argb((int) 0, 255, 255, 255));//AGB由相关工具获得,或者美工提供                     StatusBarUtil.setStatusBarDarkTheme(getActivity(), false);                } else if (y > height && y < height * 1.5) {                    rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white));                    tv_title.setTextColor(mContext.getResources().getColor(R.color.text_000000));                    ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_product));                    iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_black));                    rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white));                    rl_top.setBackgroundColor(Color.argb((int) 127, 255, 255, 255));                     StatusBarUtil.setStatusBarDarkTheme(getActivity(), true);                } else if (y > height * 1.5) {                    rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white));                    tv_title.setTextColor(mContext.getResources().getColor(R.color.text_000000));                    ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_product));                    iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_black));                    rl_top.setBackgroundColor(Color.argb((int) 255, 255, 255, 255));                     StatusBarUtil.setStatusBarDarkTheme(getActivity(), true);                }            }        });        mXrvProduct.addOnScrollListener(new RecyclerView.OnScrollListener() {            @Override            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {                super.onScrolled(recyclerView, dx, dy);                LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager();                //获取当前可见条目得索引                int firstVisibleItemPosition = manager.findFirstVisibleItemPosition();                int lastVisibleItemPosition = manager.findLastCompletelyVisibleItemPosition();                 //获取当前可见条目得itemView                View firstView = manager.findViewByPosition(firstVisibleItemPosition);                //获取当前可见条目得itemView得高度                height = firstView.getHeight();                //获取当前可见条目得偏移量                y = (firstVisibleItemPosition) * height - firstView.getTop();                 int alpha = 255 * y / (height);                if (alpha > 255) {                    alpha = 255;                }                if (alpha < 5) {                    alpha = 0;                }                 float scale = (float) dy / height;                float alphat = (255 * scale);                LogUtil2.log("滑动高度--" + y + "--" + height + "--");                if (y == height) {                    tv_title.setTextColor(mContext.getResources().getColor(R.color.white));                    ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.yuanjiao24whire));                    iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_white));                    rl_top.setBackgroundColor(Color.argb((int) 0, 255, 255, 255));//AGB由相关工具获得,或者美工提供                    StatusBarUtil.setStatusBarDarkTheme(getActivity(), false);                } else if (y > height && y < height * 1.5) {                    rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white));                    tv_title.setTextColor(mContext.getResources().getColor(R.color.text_000000));                    ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_product));                    iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_black));                    rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white));                    rl_top.setBackgroundColor(Color.argb((int) 127, 255, 255, 255));                    StatusBarUtil.setStatusBarDarkTheme(getActivity(), true);                } else if (y > height * 1.5) {                    rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white));                    tv_title.setTextColor(mContext.getResources().getColor(R.color.text_000000));                    ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_product));                    iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_black));                    rl_top.setBackgroundColor(Color.argb((int) 255, 255, 255, 255));                     StatusBarUtil.setStatusBarDarkTheme(getActivity(), true);                }              }        });     }       public void setpopLoad() {        try {            localVersionLoad = Utils.getVersionName(mContext);        } catch (Exception e) {            e.printStackTrace();        }         key = "show_home_load" + localVersion;        LogUtil2.log("=========================>>>key" + key);        LogUtil2.log("=========================>>>AccountUtils.getVersioncode()" + AccountUtils.getVersioncode());        //是否是安装的第一次        if (!AccountUtils.getVersioncodeHomeLoad().equals(key)) {            AccountUtils.putVersioncodeHomeLoad(key);              dialog = new CustomDialog(mContext, R.layout.pop_home_load, R.style.CustomDialogTheme);            dialog.setCancelable(false);            dialog.setCanceledOnTouchOutside(false);             ImageView iv_one_button = (ImageView) dialog.findViewById(R.id.iv_one_button);             iv_one_button.setOnClickListener(new View.OnClickListener() {                @Override                public void onClick(View v) {                    // TODO Auto-generated method stub                    dialog.dismiss();                 }            });            dialog.show();        }     }      private void changeStatusBarTextColor(boolean isBlack) {        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {            if (isBlack) {                getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);//设置状态栏黑色字体            } else {                getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);//恢复状态栏白色字体            }        }    }         private volatile static boolean mHasCheckAllScreen;    private volatile static boolean mIsAllScreenDevice;     public static boolean isAllScreenDevice(Context context) {        if (mHasCheckAllScreen) {            return mIsAllScreenDevice;        }        mHasCheckAllScreen = true;        mIsAllScreenDevice = false;        // 低于 API 21的,都不会是全面屏。。。        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {            return false;        }        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);        if (windowManager != null) {            Display display = windowManager.getDefaultDisplay();            Point point = new Point();            display.getRealSize(point);            float width, height;            if (point.x < point.y) {                width = point.x;                height = point.y;            } else {                width = point.y;                height = point.x;            }            if (height / width >= 1.97f) {                mIsAllScreenDevice = true;            }        }        return mIsAllScreenDevice;    }     private int dip2px(Context context, float dipValue) {        Resources r = context.getResources();        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, r.getDisplayMetrics());    }     //判断Activity是否Destroy    public static boolean isDestroy(Activity activity) {        if (activity == null || activity.isFinishing() || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed())) {            return true;        } else {            return false;        }    }     private void initListeners() {        mXrvProduct.addOnScrollListener(new RecyclerView.OnScrollListener() {            @Override            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {                super.onScrollStateChanged(recyclerView, newState);                switch (newState) {                    case 0:                        LogUtil2.log("recyclerview已经停止滚动");                         if (getActivity() != null) {                            Glide.with(getActivity()).load(R.mipmap.huadong2).into(iv_contact);                            new Handler().postDelayed(new Runnable() {                                @Override                                public void run() {                                    Glide.with(getActivity()).load(R.mipmap.jingzhi).into(iv_contact);                                }                            }, 1500);                        } //                        Glide.with(getActivity()).load(R.mipmap.jingzhi).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(iv_contact);                        break;                    case 1:                        LogUtil2.log("recyclerview正在被拖拽");                         if (getActivity() != null) {                            Glide.with(getActivity()).load(R.mipmap.huadong).into(iv_contact);                        }                          break;                    case 2:                        LogUtil2.log("recyclerview正在依靠惯性滚动");                         if (getActivity() != null) {                            Glide.with(getActivity()).load(R.mipmap.huadong).into(iv_contact);                        }                        break;                }            }             @Override            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {                super.onScrolled(recyclerView, dx, dy);             }        });     }     @Override    public void initData() {        super.initData();    }      @Override    public void onResume() {        super.onResume();     }           @Override    public void onHiddenChanged(boolean hidden) {        super.onHiddenChanged(hidden);        if (!hidden) {            hidden2 = hidden;            LogUtil2.log("==========================>>>onHiddenChangedHome" + hidden);              loopLayout.stopLoop();// 页面销毁时需要停止            loopLayout.startLoop();            StatusBarUtil.setTranslucentStatus(getActivity());            if (y <= height) {                tv_title.setTextColor(mContext.getResources().getColor(R.color.white));                ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.yuanjiao24whire));                iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_white));                rl_top.setBackgroundColor(Color.argb((int) 0, 255, 255, 255));//AGB由相关工具获得,或者美工提供                 StatusBarUtil.setStatusBarDarkTheme(getActivity(), false);            } else if (y > height && y < height * 1.5) {                rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white));                tv_title.setTextColor(mContext.getResources().getColor(R.color.text_000000));                ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_product));                iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_black));                rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white));                rl_top.setBackgroundColor(Color.argb((int) 127, 255, 255, 255));//                        changeStatusBarTextColor(false);//                        BarUtils.setColorNoTranslucent(getActivity(), getResources().getColor(R.color.transparent));//                        BarUtils.setRootViewFitsSystemWindows(getActivity(), false);                StatusBarUtil.setStatusBarDarkTheme(getActivity(), true);            } else if (y > height * 1.5) {                rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white));                tv_title.setTextColor(mContext.getResources().getColor(R.color.text_000000));                ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_product));                iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_black));                rl_top.setBackgroundColor(Color.argb((int) 255, 255, 255, 255));//                        changeStatusBarTextColor(true);//                        BarUtils.setColorNoTranslucent(getActivity(), getResources().getColor(R.color.transparent));//                        BarUtils.setRootViewFitsSystemWindows(getActivity(), false);                StatusBarUtil.setStatusBarDarkTheme(getActivity(), true);            }         } else {            hidden2 = hidden;            LogUtil2.log("==========================>>>onHiddenChanged" + hidden);            loopLayout.stopLoop();// 页面销毁时需要停止            mHomeAdapter.setIsStop(true);        }    }     @Override    public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {        if (requestCode == 1000) {            if ((grantResults.length > 0) && (grantResults[0] == PackageManager.PERMISSION_GRANTED)) {                UserBean query = UserBeanDao.query();             } else {                Toast.makeText(mContext, "手机IMEI权限未开启!", Toast.LENGTH_LONG).show();            }        }    }     public boolean checkIme() {        int permissionCheck = ContextCompat.checkSelfPermission(mContext, Manifest.permission.READ_PHONE_STATE);         if (permissionCheck != PackageManager.PERMISSION_GRANTED) {            ActivityCompat.requestPermissions((Activity) mContext, new String[]{Manifest.permission.READ_PHONE_STATE}, 1000);            return false;        } else {            //TODO            return true;        }    }     @Override    protected void initListener() {        super.initListener();        iv_back_top.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                appbar.setExpanded(true, false);                iv_back_top.setVisibility(View.GONE);                EventManager.post(new RefreshHomeArticleEvent());            }        });        ll_search.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                if (!isLogin()) {                    UIHelper.showLogin(mContext);                    return;                }                 UIHelper.showProductSearch(mContext);            }        });       }      @Override    protected void onSuccess(String response, int id) {        super.onSuccess(response, id);        switch (id) {            case 100:                LogUtil2.log("=========================>>>100" + response.toString());                mXrvProduct.refreshComplete();//                refreshLayout.finishRefresh(2000);//传入false表示刷新失败                HomeBean homeBean = GsonUtils.toObject(response, HomeBean.class);                mHomePagePlatAdList = homeBean.homePagePlatAdList;                if (null != mHomePagePlatAdList && !mHomePagePlatAdList.isEmpty()) {                     setBannerLoop(mHomePagePlatAdList);                 }                 break;             case 600://精选产品                setRecommendData(response);                break;             case 700:                LogUtil2.log("=========================>>>700" + response.toString());                setHomeBeanADV(response);                break;            case 800://提醒中心                setHomeBeanRemind(response);                break;            case 601://云学院推荐橱窗列表                setRecommendDatas(response);                break;             case 603:                RecommendListBean recommendListBean = GsonUtils.toObject(response, RecommendListBean.class);                if (recommendListBean.recommendList != null) {                    if (recommendListBean.recommendList.size() > 0) {                        tv_search.setText(recommendListBean.recommendList.get(0));                    }                 }                break;            case 604://滚动头条                LogUtil2.log("首页文章--滚动条" + response.toString());                setHomeAdviance(response);                break;            case 605://文章                LogUtil2.log("首页文章--文章" + response.toString());                ll_tab.setVisibility(View.VISIBLE);                setHomeArticle(response);                 break;         }    }     private void setHomeArticle(String response) {        if (TextUtils.isEmpty(response)) {            return;        }         final FindClassifysBean bean = GsonUtils.toObject(response, FindClassifysBean.class);        if (bean!=null){             if (!isFirstTab) {                if (articleClassifyList != null && bean.articleClassifyList.size() == articleClassifyList.size()) {                    for (int i = 0; i < bean.articleClassifyList.size(); i++) {                        for (int j = 0; j < articleClassifyList.size(); j++) {                            if (bean.articleClassifyList.get(i).uuid.equals(articleClassifyList.get(j).uuid)) {                                isSame = false;                            }                        }                     }                }             }            LogUtil2.log("第一次加载--"+isSame+"---"+isFirstTab+"--"+isRemind+"---"+isHoutai);            if (isRemind) {                isRemind=false;                if (!isSame) {                    isSame = true;                    return;                }            }else {                  appbar.setExpanded(true, false);                iv_back_top.setVisibility(View.GONE);            }         }          isFirstTab=false;        articleClassifyList = bean.articleClassifyList; //        mHomeAdapter.setHomeArticle(bean);        if (bean.articleClassifyList != null && bean.articleClassifyList.size() > 0) {            mFragments.clear();            mTitles.clear();            for (int i = 0; i < bean.articleClassifyList.size(); i++) {                ArticleClassifyListBean bean2 = bean.articleClassifyList.get(i);                 mTitles.add(bean2.name);                Bundle b = new Bundle();                b.putSerializable("bean", bean.articleClassifyList.get(i));                b.putInt("positionClick", i);                b.putSerializable("company",companyBaseBean);                Fragment f = new ArticleHomeFragment();                f.setArguments(b);                mFragments.add(f);            }            if (getActivity() != null) {                 viewpager.setAdapter(mAdapter);                tl_9.setViewPager(viewpager,mTitles);                tl_9.setCurrentTab(0);                viewpager.setCurrentItem(0);                 setTab();                if (!isFirstLay){                    LogUtil2.log("刷新--");                    mAdapter.setNewFragments();                }                 isFirstLay = false;             }        }      }     @Override    public void onPause() {        super.onPause();        Log.i("滚动高度--onPause", "展开");    }     @Override    public void onStop() {        super.onStop();        Log.i("滚动高度--onStop", "展开");        if (isRemind){            isOther=true;        }        if (appbarState == 1) {            Log.i("滚动高度--", "展开");            //展开状态         } else if (appbarState == 2) {            Log.i("滚动高度--", "折叠");            //折叠状态         }  else if (appbarState ==3){             Log.i("滚动高度--", "中间");            //中间状态         }    }     public void setTab() {          tl_9.setTextUnselectColor(getResources().getColor(R.color.text_000000));        tl_9.setTextSelectColor(getResources().getColor(R.color.white));        tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_1A75FF));        tl_9.setOnTabSelectListener(new OnTabSelectListener() {            @Override            public void onTabSelect(int position) {                if (position % 9 == 0) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_1A75FF));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_1A75FF));                } else if (position % 9 == 1) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_F05F12));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_F05F12));                } else if (position % 9 == 2) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_DD8033));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_DD8033));                } else if (position % 9 == 3) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_14BEDF));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_14BEDF));                } else if (position % 9 == 4) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_2B2EF5));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_2B2EF5));                } else if (position % 9 == 5) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_EEB01F));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_EEB01F));                } else if (position % 9 == 6) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_E92A4B));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_E92A4B));                } else if (position % 9 == 7) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_00C99E));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_00C99E));                } else if (position % 9 == 8) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_299BF5));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_299BF5));                }            }             @Override            public void onTabReselect(int position) {             }        });        viewpager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {            @Override            public void onPageScrolled(int i, float v, int i1) {             }             @Override            public void onPageSelected(int position) {//            tab_head.setCurrentTab(position);//                if (!isFirstLay){                if (mFragments != null && mFragments.size() > 0 && articleClassifyList != null && articleClassifyList.size() > 0) {                    ArticleHomeFragment fragment = (ArticleHomeFragment) mFragments.get(position);                    fragment.setRefresh(position, articleClassifyList.get(position));                }//                }//                if (position % 9 == 0) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_1A75FF));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_1A75FF));                } else if (position % 9 == 1) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_F05F12));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_F05F12));                } else if (position % 9 == 2) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_DD8033));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_DD8033));                } else if (position % 9 == 3) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_14BEDF));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_14BEDF));                } else if (position % 9 == 4) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_2B2EF5));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_2B2EF5));                } else if (position % 9 == 5) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_EEB01F));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_EEB01F));                } else if (position % 9 == 6) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_E92A4B));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_E92A4B));                } else if (position % 9 == 7) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_00C99E));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_00C99E));                } else if (position % 9 == 8) {                    tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_299BF5));//                tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_299BF5));                }             }             @Override            public void onPageScrollStateChanged(int i) {             }        });       }     @Override    public void onClickArticle(boolean isremind) {        LogUtil2.log("isRemind----"+isremind);        isRemind=isremind;    }     private class MyPagerAdapter extends FragmentPagerAdapter {         private List<String> tags;//标示fragment的tag        private FragmentManager fragmentManager;         public MyPagerAdapter(FragmentManager fm) {            super(fm);            this.tags = new ArrayList<>();            this.fragmentManager = fm;        }//        public MyPagerAdapter(FragmentManager fm) {//            super(fm);//        }         @Override        public int getCount() {            return mFragments.size();        }         @Override        public CharSequence getPageTitle(int position) {            return mTitles.get(position);        }         @Override        public Fragment getItem(int position) {            return mFragments.get(position);        }         @Override        public int getItemPosition(@NonNull Object object) {            return POSITION_NONE;        }        //这个就不说了        private String makeFragmentName(int viewId, long id) {            return "android:switcher:" + viewId + ":" + id;        }        @NonNull        @Override        public Object instantiateItem(@NonNull ViewGroup container, int position) {            tags.add(makeFragmentName(container.getId(), getItemId(position)));            Fragment fragment = (Fragment) super.instantiateItem(container, position);            this.fragmentManager.beginTransaction().show(fragment).commitAllowingStateLoss();            return fragment;        }        //根据tag查找缓存的fragment,移除缓存的fragment,替换成新的        public void setNewFragments() {            if (this.tags != null) {                FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();                for (int i = 0; i < tags.size(); i++) {                    fragmentTransaction.remove(fragmentManager.findFragmentByTag(tags.get(i)));                }                fragmentTransaction.commitAllowingStateLoss();                fragmentManager.executePendingTransactions();                tags.clear();            }            notifyDataSetChanged();        }    }     private void setBannerLoop(List<HomeBannerBean> mHomePagePlatAdList) {        // 准备数据        ArrayList<BannerInfo> bannerInfos = new ArrayList<>();        List<String> bgList = new ArrayList<>();        for (int i = 0; i < mHomePagePlatAdList.size(); i++) {            bannerInfos.add(new BannerInfo(mHomePagePlatAdList.get(i).imageUrl, mHomePagePlatAdList.get(i).url));            bgList.add(mHomePagePlatAdList.get(i).imageColour);        }         if (bannerInfos.size() == 0) {            return;        }        if (bgList.size() == 0) {            return;        }        loopLayout.setLoopData(bannerInfos);// 设置轮播数据        if (bgList != null && mContext != null) {            container.setBannerBackBg(mContext, bgList);// 背景容器设置轮播图片        }        loopLayout.setBannerBgContainer(container);        loopLayout.stopLoop();        loopLayout.startLoop();    }     private void setRecommendDatas(String response) {        if (TextUtils.isEmpty(response)) {            return;        }        FaXianListsBean bean = GsonUtils.toObject(response, FaXianListsBean.class);//        KeChengRecommendsBean recommendsBean=bean.courseRecommends.get(0);        mHomeAdapter.setHomeKeCheng(bean);    }     public static <T> List<T> getObjectList(String jsonString, Class<T> cls) {        List<T> list = new ArrayList<T>();        try {            Gson gson = new Gson();            JsonArray arry = new JsonParser().parse(jsonString).getAsJsonArray();            for (JsonElement jsonElement : arry) {                list.add(gson.fromJson(jsonElement, cls));            }        } catch (Exception e) {            e.printStackTrace();        }        return list;    }     private void setRecommendData(String response) {        if (TextUtils.isEmpty(response)) {            return;        }        HomeProductBean homeProductBean = GsonUtils.toObject(response, HomeProductBean.class);//        List<HomeBottomProductBean> homeBean =getObjectList(response, HomeBottomProductBean.class);         mHomeAdapter.setHomeBean(homeProductBean);    }     private void setHomeBeanADV(String response) {        HomeBean homeBean2 = GsonUtils.toObject(response, HomeBean.class);        mHomeAdapter.setHomeBeanADV(homeBean2);    }     private void setHomeBeanRemind(String response) {        if (TextUtils.isEmpty(response)) {            return;        }        final KaoShiStatussBean bean = GsonUtils.toObject(response, KaoShiStatussBean.class);        mHomeAdapter.setHomeRemind(bean);    }     private void setHomeAdviance(String response) {        if (TextUtils.isEmpty(response)) {            return;        }         final HeadHomeBean bean = GsonUtils.toObject(response, HeadHomeBean.class);         mHomeAdapter.setHomeAdviance(bean);    }       @Override    public void onTabReselect() {        LogUtil.e(LogUtil.CQ, "onTabReselect HomeFragment");    }          public int getNum(int endNum) {        if (endNum > 0) {            Random random = new Random();            return random.nextInt(endNum);        }        return 0;    }         @Override    public void onItemClick(int position) {    }     @Override    public void onDestroy() {        super.onDestroy();        EventManager.unregister(this);        loopLayout.stopLoop();// 页面销毁时需要停止        mHomeAdapter.setIsStop(true);         if(iv_contact != null &&  !getActivity().isDestroyed()){            Glide.with(getContext()).clear(iv_contact);            iv_contact = null;        }    }     @Override    public void onDestroyView() {        super.onDestroyView();     }     public static SetOnclickInterface listenersTOP;      @Override    public void onRefresh() {    }     @Override    public void onLoadMore() {     }         @Override    public void onBannerClick(int position, ArrayList<BannerInfo> banner) {     }     @Override    public void onChildScroll(RecyclerView recyclerView, int newState) {        switch (newState) {            case 0:                LogUtil2.log("recyclerview已经停止滚动");                 if (getActivity() != null) {                    Glide.with(getActivity()).load(R.mipmap.huadong2).into(iv_contact);                    new Handler().postDelayed(new Runnable() {                        @Override                        public void run() {                            Glide.with(getActivity()).load(R.mipmap.jingzhi).into(iv_contact);                        }                    }, 1500);                }                 break;            case 1:                LogUtil2.log("recyclerview正在被拖拽");                 if (getActivity() != null) {                    Glide.with(getActivity()).load(R.mipmap.huadong).into(iv_contact);                }                 break;            case 2:                LogUtil2.log("recyclerview正在依靠惯性滚动");                 if (getActivity() != null) {                    Glide.with(getActivity()).load(R.mipmap.huadong).into(iv_contact);                }                break;        }    } }

感谢各位的阅读!关于“如何使用Android实现上拉吸顶效果”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

如何使用Android实现上拉吸顶效果

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

如何使用Android实现上拉吸顶效果

这篇文章给大家分享的是有关如何使用Android实现上拉吸顶效果的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。具体内容如下效果图1.home_layout.xml此布局即可实现上拉标题固定在顶部
2023-06-29

Android Jetpack Compose如何实现列表吸顶效果

这篇文章主要介绍“Android Jetpack Compose如何实现列表吸顶效果”,在日常操作中,相信很多人在Android Jetpack Compose如何实现列表吸顶效果问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法
2023-06-29

Android 实现当下最流行的吸顶效果

开始逐渐领略到ItemDecoration的美~ 今天让我 使用 ItemDecoration 来完成 可推动的悬浮导航栏的效果,最终实现的效果如下图:具体实现步骤如下: 根据我前面的文章所讲的RecyclerView的基本使用,我们先来完
2022-06-06

小程序如何实现简单吸顶效果

这篇“小程序如何实现简单吸顶效果”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“小程序如何实现简单吸顶效果”文章吧。要求:1.
2023-06-30

Android进阶CoordinatorLayout协调者布局实现吸顶效果

这篇文章主要为大家介绍了Android进阶CoordinatorLayout协调者布局实现吸顶效果,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
2023-01-29

怎么在android应用中实现一个RecyclerView悬浮吸顶效果

本篇文章为大家展示了怎么在android应用中实现一个RecyclerView悬浮吸顶效果,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。MultiType-Adapter打造悬浮吸顶效果注:当前版本
2023-05-31

Android RecyclerView实现悬浮吸顶、分隔线、到底提示效果

本文中所有效果通过ItemDecoration实现,通过此实现的可以与业务解耦,让RecyclerView的模板更加简洁,不关心任何辅助性ui,github地址 一、顶部吸附效果图二、顶部不吸附效果图三、不满一屏效果四、核心实现点 1、为什
2022-06-06

Android Studio如何实现下拉列表效果

这篇文章主要讲解了“Android Studio如何实现下拉列表效果”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Android Studio如何实现下拉列表效果”吧!题目使用 ArrayA
2023-06-30

Android进阶NestedScroll嵌套滑动机制实现吸顶效果详解

这篇文章主要为大家介绍了Android进阶NestedScroll嵌套滑动机制实现吸顶效果详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
2023-01-29

Android使用PullToRefresh实现上拉加载和下拉刷新效果的代码

在没给大家介绍正文之前,先给大家介绍展示下运行图,如果大家感觉还不错,请继续往下阅读:相关阅读:分享Android中pullToRefresh的使用心得项目已同步至:https://github.com/nanchen2251/pullTo
2022-06-06

Android自定义实现顶部粘性下拉刷新效果

本文实例为大家分享了Android实现顶部粘性下拉刷新效果的具体代码,供大家参考,具体内容如下学习:视频地址 activity_view_mv代码
2023-05-30

怎么使用Android itemDecoration接口实现吸顶悬浮标题

这篇“怎么使用Android itemDecoration接口实现吸顶悬浮标题”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“
2023-07-04

CSS3+JavaScript如何实现炫酷呼吸效果

这篇文章给大家分享的是有关CSS3+JavaScript如何实现炫酷呼吸效果的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。用css3动画实现的一个简单炫酷效果,最终的效果图如下:页面结构(index.html):
2023-06-08

如何在Android中利用ScrollView实现一个顶部悬停效果

这期内容当中小编将会给大家带来有关如何在Android中利用ScrollView实现一个顶部悬停效果,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。原理:原理其实很简单就是对view的gone和visibl
2023-05-31

编程热搜

  • Python 学习之路 - Python
    一、安装Python34Windows在Python官网(https://www.python.org/downloads/)下载安装包并安装。Python的默认安装路径是:C:\Python34配置环境变量:【右键计算机】--》【属性】-
    Python 学习之路 - Python
  • chatgpt的中文全称是什么
    chatgpt的中文全称是生成型预训练变换模型。ChatGPT是什么ChatGPT是美国人工智能研究实验室OpenAI开发的一种全新聊天机器人模型,它能够通过学习和理解人类的语言来进行对话,还能根据聊天的上下文进行互动,并协助人类完成一系列
    chatgpt的中文全称是什么
  • C/C++中extern函数使用详解
  • C/C++可变参数的使用
    可变参数的使用方法远远不止以下几种,不过在C,C++中使用可变参数时要小心,在使用printf()等函数时传入的参数个数一定不能比前面的格式化字符串中的’%’符号个数少,否则会产生访问越界,运气不好的话还会导致程序崩溃
    C/C++可变参数的使用
  • css样式文件该放在哪里
  • php中数组下标必须是连续的吗
  • Python 3 教程
    Python 3 教程 Python 的 3.0 版本,常被称为 Python 3000,或简称 Py3k。相对于 Python 的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0 在设计的时候没有考虑向下兼容。 Python
    Python 3 教程
  • Python pip包管理
    一、前言    在Python中, 安装第三方模块是通过 setuptools 这个工具完成的。 Python有两个封装了 setuptools的包管理工具: easy_install  和  pip , 目前官方推荐使用 pip。    
    Python pip包管理
  • ubuntu如何重新编译内核
  • 改善Java代码之慎用java动态编译

目录