走马灯--动画实现

本文介绍了如何在Android中实现图文走动的走马灯效果,动画从右往左,内容逐渐露出,走完后控件自动隐藏。通过布局文件和核心代码ChatRoomMarquee.java的设置,详细阐述了实现过程,并提供了GitHub链接供参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目需求:图文走动,从右往左,图文从右逐渐露出,走完图文后控件隐藏。

这里写图片描述

//////////////////////////////////////////////布局文件//////////////////////////////////////////

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:background="#cc0bbe06">
    <RelativeLayout
        android:id="@+id/animation_layer"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/chat_bulletin_img"
            android:layout_width="13dp"
            android:layout_height="13dp"
            android:layout_centerVertical="true"
            android:background="@drawable/chat_room_bulletin" />

        <TextView
            android:id="@+id/bulletin_txt"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginLeft="5dp"
            android:layout_toRightOf="@id/chat_bulletin_i
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值