京东跑马灯的代码

首先呢,导入一个依赖

compile 'com.sunfusheng:marqueeview:1.3.3'


其次,给跑马灯定义布局

    

<LinearLayout
    android:padding="10dp"
    android:gravity="center_vertical"
    android:layout_margin="10dp"
    android:orientation="horizontal"

    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:text="京东快报"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <com.sunfusheng.marqueeview.MarqueeView
        android:id="@+id/marqueeView"
        android:layout_marginLeft="10dp"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        app:mvAnimDuration="1000"
        app:mvDirection="bottom_to_top"
        app:mvInterval="3000"
        app:mvTextColor="#000000"
        app:mvTextSize="14sp"
        app:mvSingleLine="true"/>
    <View
        android:layout_width="0.5dp"
        android:layout_marginTop="2dp"
        android:layout_marginBottom="2dp"
        android:background="#000000"
        android:layout_height="match_parent"/>

    <TextView
        android:layout_marginLeft="5dp"
        android:text="更多"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
LinearLayout>

获取id


初始化跑马灯的内容
List info = new ArrayList<>();
info.add("欢迎访问京东app");
info.add("大家有没有在 听课");
info.add("是不是还有人在睡觉");
info.add("你妈妈在旁边看着呢");
info.add("赶紧的好好学习吧 马上毕业了");
info.add("你没有事件睡觉了");
marqueeView.startWithList(info);


然后放入集合中



你可能感兴趣的:(京东跑马灯的代码)