跑马灯

//        跑马灯
    implementation 'com.sunfusheng:marqueeview:1.3.3'

代码块

if (holder instanceof MyViewHolder_MarQuee){

            //        跑马灯
            List<String> info = new ArrayList<>();
            info.add("心中有阳光,脚底有力量!心中有阳光,脚底有力量!心中有阳光,脚底有力量!");
            info.add("升级4G大显存!Nvme协议Pcie SSD,速度快人一步");
            info.add("购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)");
            info.add("全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G");
            info.add("京东月饼让爱更圆满京东自营,闪电配送,更多惊喜");
            info.add("【i5 MX150 2G显存】全高清窄边框 8G内存 256固态硬盘 支持指纹识别 预装WIN10系统");
            //            开启跑马灯
            ((MyViewHolder_MarQuee) holder).marqueeView.startWithList(info);

            // 在代码里设置动画
            ((MyViewHolder_MarQuee) holder).marqueeView.startWithList(info, R.anim.anim_bottom_in, R.anim.anim_top_out);

        }

layout布局

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:background="@drawable/select_animation01"
        android:orientation="horizontal">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="3dp"
            android:text="京东快报" />

        <com.sunfusheng.marqueeview.MarqueeView
            android:id="@+id/marquee"
            android:layout_width="match_parent"
            android:layout_height="28dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="3dp"
            android:layout_weight="1"
            app:mvAnimDuration="1000"
            app:mvDirection="bottom_to_top"
            app:mvInterval="3000"
            app:mvSingleLine="true"
            app:mvTextColor="@android:color/black"
            app:mvTextSize="15sp"></com.sunfusheng.marqueeview.MarqueeView>
    </LinearLayout>
</LinearLayout>

shape文件

select_animation01

<?xml version="1.0" encoding="utf-8"?>
<shape
    android:shape="rectangle"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <size android:width="100dp" android:height="30dp"/>
    <corners android:radius="15dp"/>
    <solid android:color="@color/White"/>
</shape>


select_animation02

<?xml version="1.0" encoding="utf-8"?>
<shape
    android:shape="rectangle"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <size android:width="100dp" android:height="45dp"/>
    <corners android:radius="15dp"/>
    <solid android:color="#F8F4F5"/>
</shape>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值