Android 仿快手视频列表,RecyclerView与Banner联动效果

这是看到群里讨论过快手APP的一个观看他人视频列表的一个联动效果,但是并不是完全按照这个软件的效果来做的,只是参考,并不是完全仿照这个软件来做的,没时间去优化排版问题了,请见谅,如图:

实现效果如下:

1.主函数代码:

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.example.mytestapplication.R;
import com.example.mytestapplication.adapter.ImageAdapter;
import com.example.mytestapplication.bean.DataBean;
import com.example.mytestapplication.bean.SelectBean;
import com.example.mytestapplication.databinding.ActivityYouthBannerBinding;
import com.example.mytestapplication.pbl.FullyStaggeredGridLayoutManager;
import com.example.mytestapplication.recycler.BannerScreenAdapter;
import com.example.mytestapplication.recycler.ScreenAllAdapter;
import com.google.android.material.snackbar.Snackbar;
import com.youth.banner.indicator.CircleIndicator;
import com.youth.banner.listener.OnBannerListener;
import com.youth.banner.listener.OnPageChangeListener;

import java.util.ArrayList;
import java.util.List;

/**
 * https://github.com/youth5201314/banner
 *
 * https://blog.csdn.net/u014628886/article/details/52074383
 *
 * https://blog.csdn.net/itTalmud/article/details/130330097
 */
public class YouthBannerActivity extends AppCompatActivity {

    private ActivityYouthBannerBinding binding;
    private FullyStaggeredGridLayoutManager slm = null;
    private List<Integer> picList;
    private ImageAdapter adapter;
    private Integer[] mImgIds = {R.drawable.image7, R.drawable.image8, R.drawable.image9, R.drawable.image10, R.drawable.image11};
    private BannerScreenAdapter mBannerScreenAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.activity_youth_banner, null, false);
        setContentView(binding.getRoot());

        binding.btTest.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                binding.banner.setCurrentItem(2);
                binding.banner.stop();
            }
        });
        initData();

    }

    private void initData() {

        // 轮播的图片集合
        picList = new ArrayList<>();

        picList.add(R.mipmap.aa);
        picList.add(R.mipmap.ab);
        picList.add(R.mipmap.ac);
        picList.add(R.mipmap.mm);
        picList.add(R.mipmap.aa);
        picList.add(R.mipmap.ab);
        picList.add(R.mipmap.ac);
        picList.add(R.mipmap.mm);
        picList.add(R.mipmap.aa);
        picList.add(R.mipmap.ab);
        picList.add(R.mipmap.ac);
        picList.add(R.mipmap.mm);

        //模拟数据源
        ArrayList imgLists = new ArrayList<>();
        for (int i = 0; i < mImgIds.length; i++) {
            imgLists.add(mImgIds[i]);
        }

        List<SelectBean> selectBeans = SelectBean.getTestData();

        List<DataBean> datas =  DataBean.getTestData2();

        //自定义的图片适配器,也可以使用默认的BannerImageAdapter
        adapter = new ImageAdapter(datas);

        binding.banner.setAdapter(adapter)
//              .setCurrentItem(0,false)
                //添加生命周期观察者
                .addBannerLifecycleObserver(this)
                //设置指示器
                .setIndicator(new CircleIndicator(this))
                .setOnBannerListener((data, position) -> {
//                    Snackbar.make(binding.banner, ((DataBean) data).title, Snackbar.LENGTH_SHORT).show();
//                    LogUtils.d("position:" + position);
                });

        //添加item之间切换时的间距(如果使用了画廊效果就不要添加间距了,因为内部已经添加过了)
//        banner.addPageTransformer(new MarginPageTransformer( BannerUtils.dp2px(10)));

        //Banner点击事件
        binding.banner.setOnBannerListener(new OnBannerListener() {
            @Override
            public void OnBannerClick(Object data, int position) {
                //点击Banner,关联对应的RecyclerView数据
                binding.rvScreen.scrollToPosition(position);
                mBannerScreenAdapter.setPosition(position);
                mBannerScreenAdapter.notifyDataSetChanged();
            }
        });

//        binding.banner.setOnScrollChangeListener(new View.OnScrollChangeListener() {
//            @Override
//            public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
//
//            }
//        });
        //Banner滑动监听事件
        binding.banner.addOnPageChangeListener(new OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                //点击Banner,关联对应的RecyclerView数据
                binding.rvScreen.scrollToPosition(position);
                mBannerScreenAdapter.setPosition(position);
                mBannerScreenAdapter.notifyDataSetChanged();
            }

            @Override
            public void onPageSelected(int position) {

            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });


        mBannerScreenAdapter = new BannerScreenAdapter(this, selectBeans);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        binding.rvScreen.setLayoutManager(layoutManager);
        binding.rvScreen.setAdapter(mBannerScreenAdapter);

        mBannerScreenAdapter.setOnItemClickListener(new BannerScreenAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                binding.banner.setCurrentItem(position+1);
                binding.banner.stop();
            }
        });
    }

    @Override
    protected void onStop() {
        super.onStop();

    }

    @Override
    protected void onResume() {
        super.onResume();


    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

    }
}

主函数布局:

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

    </data>

    <RelativeLayout xmlns:banner="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.youth.banner.Banner
            android:id="@+id/banner"
            android:layout_width="280dp"
            android:layout_height="180dp"
            android:layout_margin="10dp"
            banner:banner_indicator_normal_color="@android:color/white"
            banner:banner_indicator_selected_color="@color/purple_500"
            banner:banner_radius="5dp" />

        <com.youth.banner.indicator.RoundLinesIndicator
            android:id="@+id/indicator"
            android:layout_width="300dp"
            android:layout_height="20dp"
            android:layout_below="@+id/banner"
            android:layout_centerHorizontal="true"
            android:visibility="gone" />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rvScreen"
            android:layout_margin="10dp"
            android:layout_width="100dp"
            android:layout_height="180dp"
            android:layout_alignParentRight="true"/>

        <Button
            android:id="@+id/btTest"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="刷新"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="20dp" />
    </RelativeLayout>
</layout>

实体类:

import com.example.mytestapplication.R;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class SelectBean implements Serializable {
    public Integer imageRes;

    public Integer getImageRes() {
        return imageRes;
    }

    public void setImageRes(Integer imageRes) {
        this.imageRes = imageRes;
    }

    public boolean isSelect() {
        return isSelect;
    }

    public void setSelect(boolean select) {
        isSelect = select;
    }

    public boolean isSelect;

    public SelectBean(Integer imageRes, boolean isSelect) {
        this.imageRes = imageRes;
        this.isSelect = isSelect;
    }

//    public SelectBean(String imageUrl, String title, int viewType) {
//        this.imageUrl = imageUrl;
//        this.title = title;
//        this.viewType = viewType;
//    }

    public static List<SelectBean> getTestData() {
        List<SelectBean> list = new ArrayList<>();
        list.add(new SelectBean(R.drawable.image7, false));
        list.add(new SelectBean(R.drawable.image8, false));
        list.add(new SelectBean(R.drawable.image9, false));
        list.add(new SelectBean(R.drawable.image10, false));
        list.add(new SelectBean(R.drawable.image11, false));
        return list;
    }

    public static List<String> getColors(int size) {
        List<String> list = new ArrayList<>();
        for(int i = 0; i < size; i++) {
            list.add(getRandColor());
        }
        return list;
    }

    /**
     * 获取十六进制的颜色代码.例如  "#5A6677"
     * 分别取R、G、B的随机值,然后加起来即可
     *
     * @return String
     */
    public static String getRandColor() {
        String R, G, B;
        Random random = new Random();
        R = Integer.toHexString(random.nextInt(256)).toUpperCase();
        G = Integer.toHexString(random.nextInt(256)).toUpperCase();
        B = Integer.toHexString(random.nextInt(256)).toUpperCase();

        R = R.length() == 1 ? "0" + R : R;
        G = G.length() == 1 ? "0" + G : G;
        B = B.length() == 1 ? "0" + B : B;

        return "#" + R + G + B;
    }
}
import com.example.mytestapplication.R;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class DataBean {
    public Integer imageRes;
    public String imageUrl;
    public String title;
    public int viewType;

    public DataBean(Integer imageRes, String title, int viewType) {
        this.imageRes = imageRes;
        this.title = title;
        this.viewType = viewType;
    }

    public DataBean(String imageUrl, String title, int viewType) {
        this.imageUrl = imageUrl;
        this.title = title;
        this.viewType = viewType;
    }

    public static List<DataBean> getTestData() {
        List<DataBean> list = new ArrayList<>();
        list.add(new DataBean(R.drawable.image1, "相信自己,你努力的样子真的很美", 1));
        list.add(new DataBean(R.drawable.image2, "极致简约,梦幻小屋", 3));
        list.add(new DataBean(R.drawable.image3, "超级卖梦人", 3));
        list.add(new DataBean(R.drawable.image4, "夏季新搭配", 1));
        list.add(new DataBean(R.drawable.image5, "绝美风格搭配", 1));
        list.add(new DataBean(R.drawable.image6, "微微一笑 很倾城", 3));
        return list;
    }

    public static List<DataBean> getTestData2() {
        List<DataBean> list = new ArrayList<>();
        list.add(new DataBean(R.drawable.image7, "听风.赏雨", 3));
        list.add(new DataBean(R.drawable.image8, "迪丽热巴.迪力木拉提", 1));
        list.add(new DataBean(R.drawable.image9, "爱美.人间有之", 3));
        list.add(new DataBean(R.drawable.image10, "洋洋洋.气质篇", 1));
        list.add(new DataBean(R.drawable.image11, "生活的态度", 3));
        return list;
    }

    /**
     * 仿淘宝商品详情第一个是视频
     * @return
     */
    public static List<DataBean> getTestDataVideo() {
        List<DataBean> list = new ArrayList<>();
        list.add(new DataBean("http://vfx.mtime.cn/Video/2019/03/09/mp4/190309153658147087.mp4", "第一个放视频", 2));
        list.add(new DataBean(R.drawable.image7, "听风.赏雨", 1));
        list.add(new DataBean(R.drawable.image8, "迪丽热巴.迪力木拉提", 1));
        list.add(new DataBean(R.drawable.image9, "爱美.人间有之", 1));
        list.add(new DataBean(R.drawable.image10, "洋洋洋.气质篇", 1));
        list.add(new DataBean(R.drawable.image11, "生活的态度", 1));
        return list;
    }

    public static List<DataBean> getTestData3() {
        List<DataBean> list = new ArrayList<>();
        list.add(new DataBean("https://img.zcool.cn/community/013de756fb63036ac7257948747896.jpg", null, 1));
        list.add(new DataBean("https://img.zcool.cn/community/01639a56fb62ff6ac725794891960d.jpg", null, 1));
        list.add(new DataBean("https://img.zcool.cn/community/01270156fb62fd6ac72579485aa893.jpg", null, 1));
        list.add(new DataBean("https://img.zcool.cn/community/01233056fb62fe32f875a9447400e1.jpg", null, 1));
        list.add(new DataBean("https://img.zcool.cn/community/016a2256fb63006ac7257948f83349.jpg", null, 1));
        return list;
    }

    public static List<DataBean> getVideos() {
        List<DataBean> list = new ArrayList<>();
        list.add(new DataBean("http://vfx.mtime.cn/Video/2019/03/21/mp4/190321153853126488.mp4", null, 0));
        list.add(new DataBean("http://vfx.mtime.cn/Video/2019/03/18/mp4/190318231014076505.mp4", null, 0));
        list.add(new DataBean("http://vfx.mtime.cn/Video/2019/03/18/mp4/190318214226685784.mp4", null, 0));
        list.add(new DataBean("http://vfx.mtime.cn/Video/2019/03/19/mp4/190319125415785691.mp4", null, 0));
        list.add(new DataBean("http://vfx.mtime.cn/Video/2019/03/14/mp4/190314223540373995.mp4", null, 0));
        list.add(new DataBean("http://vfx.mtime.cn/Video/2019/03/14/mp4/190314102306987969.mp4", null, 0));
        return list;
    }


    public static List<String> getColors(int size) {
        List<String> list = new ArrayList<>();
        for(int i = 0; i < size; i++) {
            list.add(getRandColor());
        }
        return list;
    }

    /**
     * 获取十六进制的颜色代码.例如  "#5A6677"
     * 分别取R、G、B的随机值,然后加起来即可
     *
     * @return String
     */
    public static String getRandColor() {
        String R, G, B;
        Random random = new Random();
        R = Integer.toHexString(random.nextInt(256)).toUpperCase();
        G = Integer.toHexString(random.nextInt(256)).toUpperCase();
        B = Integer.toHexString(random.nextInt(256)).toUpperCase();

        R = R.length() == 1 ? "0" + R : R;
        G = G.length() == 1 ? "0" + G : G;
        B = B.length() == 1 ? "0" + B : B;

        return "#" + R + G + B;
    }
}

适配器:

import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.mytestapplication.bean.DataBean;
import com.example.mytestapplication.viewholder.ImageHolder;
import com.youth.banner.adapter.BannerAdapter;

import java.util.List;


/**
 * 自定义布局,图片
 */
public class ImageAdapter extends BannerAdapter<DataBean, ImageHolder> {

    public ImageAdapter(List<DataBean> mDatas) {
        //设置数据,也可以调用banner提供的方法,或者自己在adapter中实现
        super(mDatas);
    }

    //更新数据
    public void updateData(List<DataBean> data) {
        //这里的代码自己发挥,比如如下的写法等等
        mDatas.clear();
        mDatas.addAll(data);
        notifyDataSetChanged();
    }


    //创建ViewHolder,可以用viewType这个字段来区分不同的ViewHolder
    @Override
    public ImageHolder onCreateHolder(ViewGroup parent, int viewType) {
        ImageView imageView = new ImageView(parent.getContext());
        //注意,必须设置为match_parent,这个是viewpager2强制要求的
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        imageView.setLayoutParams(params);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        return new ImageHolder(imageView);
    }

    @Override
    public void onBindView(ImageHolder holder, DataBean data, int position, int size) {
        holder.imageView.setImageResource(data.imageRes);
    }

}
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.recyclerview.widget.RecyclerView;

import com.example.mytestapplication.R;
import com.example.mytestapplication.bean.SelectBean;

import java.util.List;

/**
 * https://www.itguest.com/post/aeijeb1a1.html
 * @date 2020/12/10
 * desc
 */
public class BannerScreenAdapter extends RecyclerView.Adapter<BannerScreenAdapter.ViewHolder> {

    private Context context;
    private List<Integer> mDataList;
    private List<SelectBean> mSelectBeanList;
    private OnItemClickListener onItemClickListener;
    private int mPosition = -1;
    private int currentPosition;
    private boolean isClick;
    private LinearLayout llView;

//    public BannerScreenAdapter(Context context, List<Integer> dataList) {
//        this.context = context;
//        this.mDataList = dataList;
//    }

    public BannerScreenAdapter(Context context, List<SelectBean> dataList) {
        this.context = context;
        this.mSelectBeanList = dataList;
    }

    @Override
    public int getItemCount() {
//        return Integer.MAX_VALUE;
        return mSelectBeanList.size();
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        final View view = LayoutInflater.from(context).inflate(R.layout.item_banner_screen, parent, false);
        final ViewHolder vh = new ViewHolder(view);
        int adapterPosition = vh.getAdapterPosition();
        int position = vh.getPosition();

//        boolean isSelect = mSelectBeanList.get(position).isSelect;
//        if(isSelect){
//            llView.setBackgroundResource(R.drawable.shape_bg_blue);
//        }else {
//            llView.setBackgroundResource(R.drawable.tab_bg);
//        }

//        view.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                int adapterPosition = vh.getAdapterPosition();
//                int position = vh.getPosition();
                for (int i = 0; i < mSelectBeanList.size(); i++) {
                    if(adapterPosition == i){
                        mSelectBeanList.get(vh.getPosition()).setSelect(true);
                        setCurrentPosition(vh.getAdapterPosition(), true);
                    }else {
                        mSelectBeanList.get(vh.getPosition()).setSelect(false);
                        setCurrentPosition(vh.getAdapterPosition(), false);
                    }
                }
//                if(!isClick){
//                    //调用setCurrentPosition()方法
//                    setCurrentPosition(vh.getAdapterPosition(),true);//记录并设为true
//                }else {
//                    //当某项点击状态为true 点击的时候判断当前位置和getAbsoluteAdapterPosition()为点击更新后适配器的位置是否一致?不一致说明点击了新的选项,记录isClick为false 更新新的位置。
//                    setCurrentPosition(vh.getAdapterPosition(), //记录当前点击
//                            getCurrentPosition()!=vh.getAdapterPosition());
//                }
//
//                notifyDataSetChanged();
//                onItemClickListener.onItemClick(vh.getPosition());
                notifyItemChanged(position);
//            }
//        });
        return vh;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, @SuppressLint("RecyclerView") int position) {
//        int newPos = position % mDataList.size();
        int newPos = position % mSelectBeanList.size();
        holder.mDisplay.setImageResource(mSelectBeanList.get(newPos).getImageRes());
        holder.itemView.setTag(position);
        holder.mLlView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPosition = position;
//                mSelectBeanList.get(position).setSelect(true);
                notifyDataSetChanged();
                onItemClickListener.onItemClick(position);
            }
        });
        boolean isSelect = mSelectBeanList.get(getCurrentPosition()).isSelect;
//        if(getCurrentPosition() == position && isSelect){
        if(mPosition == position){
//            holder.mLlView.setBackgroundResource(R.drawable.shape_bg_blue);
            //单选:设置选择的背景
            holder.mLlView.setBackgroundResource(R.drawable.tab_bg);
            //选中后设置缩放动画:将图片放大一些
            ValueAnimator valueAnimator = ValueAnimator.ofFloat(1.0f,1.1f);
            valueAnimator.setDuration(500);
            valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    //获取动画属性值
                    float value = (float) animation.getAnimatedValue();
                    holder.mDisplay.setScaleX(value);
                    holder.mDisplay.setScaleY(value);
                }
            });
            valueAnimator.start();
        }else {
            holder.mLlView.setBackgroundResource(R.drawable.shape_transparent_bg);
        }
    }


    class ViewHolder extends RecyclerView.ViewHolder {
        ImageView mDisplay;
        LinearLayout mLlView;

        public ViewHolder(View itemView) {
            super(itemView);
            mDisplay = itemView.findViewById(R.id.iv_display);
            mLlView = itemView.findViewById(R.id.ll_view);
        }
    }

    public void setOnItemClickListener(OnItemClickListener listener) {
        this.onItemClickListener = listener;
    }

    public interface OnItemClickListener {
        void onItemClick(int position);
    }

    //创建getCurrentPosition 返回当前位置
    private int getCurrentPosition() {
        return currentPosition;
    }
    //创建setCurrentPosition方法 记录当前点击选项和点击状态
    public void setCurrentPosition(int currentPosition,boolean isClick){
        this.currentPosition=currentPosition;
        this.isClick=isClick;
    }

    public void setPosition(int position){
        this.mPosition = position;
    }
}

shape选择背景: 

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:gravity="center">
        <shape>
            <!-- 设置圆角 -->
            <corners android:radius="5dp" />
            <!-- 设置边框 -->
            <stroke
                android:width="1dp"
                android:color="@color/transparent" />
        </shape>
    </item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:gravity="center">
        <shape>
            <!-- 设置圆角 -->
            <corners android:radius="5dp" />
            <!-- 设置边框 -->
            <stroke
                android:width="1dp"
                android:color="@color/teal_700" />
        </shape>
    </item>
</layer-list>

颜色:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="purple_200">#FFBB86FC</color>
    <color name="purple_500">#FF6200EE</color>
    <color name="purple_700">#FF3700B3</color>
    <color name="teal_200">#FF03DAC5</color>
    <color name="teal_700">#FF018786</color>
    <color name="black">#FF000000</color>
    <color name="white">#FFFFFFFF</color>
    <color name="grey_666">#666666</color>
    <color name="transparent">#00000000</color>
</resources>

适配器布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="80dp"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:id="@+id/ll_view"
    android:gravity="center"
    android:background="@color/white"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/iv_display"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:padding="1dp"
        tools:src="@mipmap/ic_launcher" />

</LinearLayout>

依赖文件build.gradle.kts:

plugins {
    id("com.android.application")
}

android {
    namespace = "com.example.mytestapplication"
    compileSdk = 33

    dataBinding {
        enable = true
    }

    defaultConfig {
        applicationId = "com.example.mytestapplication"
        minSdk = 24
        targetSdk = 33
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    buildFeatures {
        viewBinding = true
    }
}

dependencies {

    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("com.google.android.material:material:1.8.0")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.1")
    implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1")
    implementation("androidx.navigation:navigation-fragment:2.5.3")
    implementation("androidx.navigation:navigation-ui:2.5.3")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

    implementation ("com.github.bumptech.glide:glide:4.12.0")
    implementation ("androidx.palette:palette:1.0.0")
    implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
//    implementation ("com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.22")

    implementation ("io.github.youth5201314:banner:2.2.1")
}

清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <!--允许Glide监视连接状态,并在用户从断开连接到已连接网络的状态。-->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyTestApplication"
        tools:targetApi="31">
        <activity
            android:name=".youth.YouthBannerActivity"
            android:exported="true"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

2.图片如下:

项目源码:点击下载源码

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/324526.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

[链路层] 点对点协议 PPP

目录 1、PPP协议的特点 2、PPP协议的组成和帧格式 3、PPP协议的工作状态 目前使用得最广泛的数据链路层协议是点对点协议PPP(Point-to-Point Protocol)。 1、PPP协议的特点 我们知道&#xff0c;互联网用户通常都要连接到某个 ISP 才能接入到互联网。PPP 协议就是用户计算机…

【物以类聚】给el-image预览多张图片增加提示文字,让每张图片有所分类

【物以类聚】给el-image预览多张图片增加提示文字&#xff0c;让每张图片有所分类 一、需求二、el-image三、实施步骤3.1 导包3.2 改造3.3 引入 三、效果 一、需求 点击地图上的一张图片&#xff0c;弹出所有相关的图片资源&#xff0c;图片资源上显示每个图片的所属类型。 二…

一文读懂「Large Language Model,LLM」大语言模型

中国大语言模型产业价值链 资料 艾瑞咨询&#xff1a;https://www.iresearch.com.cn/Detail/report?id4166&isfree0&type

五指CMS copyfrom.php SQL注入漏洞复现(CVE-2023-52064)

0x01 产品简介 WUZHI CMS是北京五指互联科技有限公司 的一套基于PHP和MySQL的开源内容管理系统,响应式布局,一个网站兼容多个终端 微信接口全支持,快速构建微营销平台 开放接口,支持第三方APP无缝接入。 0x02 漏洞概述 Wuzhicms 内容管理系统的/core/admin/copyfrom.p…

vue基于spring boot框架的发艺美发店理发店管理系统的设计q9xpe

店铺信息、美发信息是发艺美发店管理系统的重要组成部分&#xff0c;信息清晰、详细、准确&#xff0c;能够有效地促进发艺美发店管理系统的运行[5]。基础设定函数是对整个系统的总体布局进行合理安排&#xff0c;包括&#xff1a;店铺活动、物品信息、领用信息等。通过对各类资…

openpyxl绘制图表

嘿&#xff0c;你是不是在处理Excel文件时感到束手无策&#xff1f;是不是想要一个简单而又强大的工具来处理数据分析和图表制作&#xff1f;别担心&#xff0c;我们有解决方案&#xff01;让我向你介绍openpyxl&#xff0c;这是一个Python库&#xff0c;专门用于处理Excel文件…

通过myBatis将sql语句返回的值自动包装成一个java对象(2)

1.之前我们是如何执行一个sql语句自动包装成一个java对象呢&#xff1f; 1.创建一个mapper.xml&#xff0c;定义 执行的语句名字 和 包装成什么类 2.在总的配置文件里申明这个mapper 3.在java里通过sqlSession执行mapper里定义好的内容 我们还可以使用另一种方法实现第三步。现…

力扣每日一练(24-1-16)

我一开始想到的是&#xff0c;如果数字相同则加一。 然而&#xff0c;对了一点点&#xff0c;而已。 高手的方法不是普通人在几分钟内能想得出来的&#xff0c;hh 继续补充&#xff1a; 如果数字不同则减一&#xff0c;如果计数到达了0&#xff0c;则更新数字&#xff0c;最…

AWS边缘媒体安全交付方案

企业如何在AWS上的边缘站点&#xff0c;安全的将优质视频内容交付给用户&#xff0c;并且禁止哪些未经过授权的访问&#xff1f;九河云将基于AWS平台提供边缘媒体安全交付解决方案 解决方案详情 在通过 Amazon CloudFront 交付时&#xff0c;免受未经授权的访问。基于添加到交…

云畅科技技术中心被认定为湖南省省级企业技术中心

近日&#xff0c;湖南省工业和信息化厅公布《2023年第二批湖南省省级企业技术中心(第29批)》&#xff0c;云畅科技技术中心作为研发设计型代表入选。 省级企业技术中心是强化企业技术创新主体地位&#xff0c;增强企业自主创新能力&#xff0c;推动工业企业高质量发展的一个重要…

数据结构学习 jz59 滑动窗口的最大值

关键词&#xff1a;排序 大顶堆 双端队列 题目&#xff1a; 望远镜中最高的海拔 方法一&#xff1a;维护一个辅助队列。 方法二&#xff1a;大顶堆。 我还在主站 239 写了找最小值的方法。 方法一&#xff1a;最优解 这个方法和jz30维护一个非严格递减的辅助栈是基本一样的…

第 379 场 LeetCode 周赛题解

A 对角线最长的矩形的面积 模拟 class Solution { public:int areaOfMaxDiagonal(vector<vector<int>> &dimensions) {int res 0, len2 0;for (auto &x: dimensions)if (x[0] * x[0] x[1] * x[1] > len2 || x[0] * x[0] x[1] * x[1] len2 &&am…

安全强化学习笔记

这里写自定义目录标题 参考资料 Safe Reinforcement Learning环境算法CPO 2017 ICMLPCPO 2019 ICLRFOCOPS 2020 NIPSCRPO 2021 ICMLCUP 2022 NIPS TRPO 如何看懂TRPO里所有的数学推导细节? - 小小何先生的回答 - 知乎 参考资料 Safe Reinforcement Learning 安全/约束强化学…

排序算法之七:归并排序(非递归)

1.非递归实现思路 我们之前学习了递归实现的归并排序&#xff0c;是分治的思想&#xff0c;即先分解&#xff0c;再归并 这篇文章我们讲一下非递归的实现 非递归实现的思路是模拟递归的过程&#xff0c;在递归过程中&#xff0c;我们找key将数组分成左右数组&#xff0c;然后…

uni-table改表头的样式,uniapp项目,颜色,字体颜色

:first-child,:nth-child选择器的使用和隔行变色_firstchild怎么用-CSDN博客

Rocketmq rust版本-开篇

我是蚂蚁背大象(Apache EventMesh PMC&Committer)&#xff0c;文章对你有帮助给Rocketmq-rust star,关注我GitHub:mxsm&#xff0c;文章有不正确的地方请您斧正,创建ISSUE提交PR~谢谢! Emal:mxsmapache.com Rust重构Rocketmq,大家好我是mxsm(Apache EventMesh PMC&Comm…

高级分布式系统目录汇总

临近《高级分布式系统》考试&#xff0c;所以一边复习((⊙o⊙)…&#xff0c;其实是预习&#xff0c;哈哈^_^)&#xff0c;一边写高级分布式博客。先将高级分布式章节以及相关博客罗列如下&#xff0c;欢迎和大家一起学习。资料部分参考上了以下教材&#xff1a; 分布式实时系统…

css 前端实现通过css动画实现进度条动态加载效果

效果图 代码 CommonProcess.vue 进度条动态加载组件代码 <!-- 进度条组件 --> <template><div class"common_process"><div v-for"(item, index) in dataList" :key"processType index" class"common_process_item…

Qt6入门教程 6:Qt元对象系统

目录 一.什么是Qt元对象系统&#xff1f; 二.编译时Qt Creator偷摸做了哪些事情&#xff1f; 1.uic 2.rcc 3.moc 一.什么是Qt元对象系统&#xff1f; Qt中的元对象系统&#xff08;Meta-Object System&#xff09;提供了对象间通信的信号和槽机制、运行时类型信息和动态属…

算法复习——01背包

01背包 DP分析法要素有&#xff1a;集合&#xff0c;属性&#xff0c;状态计算 &#xff08;集合是指只考虑前i个&#xff0c;总体积小于等于j的所有选法&#xff0c;存取的属性是所有选法的最大值&#xff09; 状态方程计算&#xff08;所有选法可以分为2种不同的子集&#x…