MarqueeViewLibrary

简介:跑马灯
更多:作者   提 Bug   
标签:
跑马灯-

通过 MarqueeFactory 来提供各种样式的跑马灯 View, 支持自定义跑马灯 ItemView

效果图

使用

Gradle:

compile 'com.gongwen:marqueelibrary:1.0.4'

属性

Attribute 属性 Description 描述
marqueeInterval 翻页时间间隔
marqueeAnimDuration 动画执行时间
marqueeAnimIn marquee in 动画
marqueeAnimOut marquee out 动画

通过自定义 MarqueeFactory 来设置 ItemView

继承自 MarqueeFactory,通过泛型指定 ItemView 类型以及 ItemData 类型,之后实现 generateMarqueeItemView 方法,提供 ItemView,并为 ItemView 设置数据即可。

例如:
public class NoticeMF extends MarqueeFactory<TextView, String> {
    private LayoutInflater inflater;

    public NoticeMF(Context mContext) {
        super(mContext);
        inflater = LayoutInflater.from(mContext);
    }

    @Override
    public TextView generateMarqueeItemView(String data) {
        TextView mView = (TextView) inflater.inflate(R.layout.notice_item, null);
        mView.setText(data);
        return mView;
    }
}

设置列表数据

适用于仅设置一次数据源
MarqueeFactory marqueeFactory = new NoticeMF(this);
marqueeFactory.setData(datas);
###### 适用于多次设置数据源
MarqueeFactory marqueeFactory = new NoticeMF(this);
marqueeFactory.resetData(datas);
#### 设置事件监听
marqueeFactory.setOnItemClickListener(new MarqueeFactory.OnItemClickListener() {
            @Override
            public void onItemClickListener(MarqueeFactory.ViewHolder holder) {
                Toast.makeText(MainActivity.this, holder.data, Toast.LENGTH_SHORT).show();
            }
});

MarqueeView 设置 Factory

marqueeView.setMarqueeFactory(marqueeFactory);

License

Copyright (C) 2016 1798550470@qq.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
自己记录、分享给好友:
Android 开发经验分享
Android 开发经验分享