Giter VIP home page Giter VIP logo

marqueelayoutlibrary's Introduction

##一个支持四个方向循环滚动的自定义控件

Android Arsenal

效果图

使用

compile 'com.oushangfeng:MarqueeLayout:1.0.2'

属性

Attribute 属性 Description 描述
switchTime 多久滚动一次的时间间隔
scrollTime 一次滚动的时间
orientation 滚动的方向,有up、down、left、right四种方向
enableAlphaAnim 是否开启滑动时子View的透明度渐变
enableScaleAnim 是否开启滑动时子View的缩放渐变

XML

<com.oushangfeng.marqueelayout.MarqueeLayout
    android:id="@+id/marquee_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:background="#118866"
    app:enableAlphaAnim="true"
    app:enableScaleAnim="false"
    app:orientation="up">

</com.oushangfeng.marqueelayout.MarqueeLayout>

<com.oushangfeng.marqueelayout.MarqueeLayout
    android:id="@+id/marquee_layout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/marquee_layout"
    android:background="#dcdcdc"
    app:enableAlphaAnim="true"
    app:enableScaleAnim="true"
    app:orientation="left">

</com.oushangfeng.marqueelayout.MarqueeLayout>

填充布局和数据,点击事件可在InitViewCallBack中自己处理

mMarqueeLayout = (MarqueeLayout) findViewById(R.id.marquee_layout);
final List<String> list = new ArrayList<>();
list.add("我听见了你的声音 也藏着颗不敢见的心");
list.add("我们的爱情到这刚刚好 剩不多也不少 还能忘掉");
list.add("像海浪撞过了山丘以后还能撑多久 他可能只为你赞美一句后往回流");
list.add("少了有点不甘 但多了太烦");
MarqueeLayoutAdapter<String> adapter = new MarqueeLayoutAdapter<>();
adapter.setCustomView(mMarqueeLayout, R.layout.item_simple_text, list, new MarqueeLayoutAdapter.InitViewCallBack<String>() {
    @Override
    public void init(View view, int position, String item) {
        ((TextView) view).setText(item);
    }
});
mMarqueeLayout.setAdapter(adapter);
mMarqueeLayout.start();


mMarqueeLayout1 = (MarqueeLayout) findViewById(R.id.marquee_layout1);
final List<String> imgs = new ArrayList<>();
imgs.add("http://img3.imgtn.bdimg.com/it/u=936722914,2010466745&fm=11&gp=0.jpg");
imgs.add("http://img5.imgtn.bdimg.com/it/u=793061750,504065085&fm=11&gp=0.jpg");
imgs.add("http://img5.imgtn.bdimg.com/it/u=506823331,38014690&fm=11&gp=0.jpg");
imgs.add("http://h.hiphotos.baidu.com/baike/pic/item/2fdda3cc7cd98d10e6a5b4aa273fb80e7bec903c.jpg");
MarqueeLayoutAdapter<String> adapter1 = new MarqueeLayoutAdapter<>();
adapter1.setCustomView(mMarqueeLayout, R.layout.item_simple_image, imgs, new MarqueeLayoutAdapter.InitViewCallBack<String>() {
    @Override
    public void init(View view, int position, String item) {
        Glide.with(view.getContext()).load(item).into((ImageView) view);
    }
});
mMarqueeLayout1.setAdapter(adapter1);
mMarqueeLayout1.start();

注意

主工程需要依赖support包

License

Copyright 2016 oubowu

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.

marqueelayoutlibrary's People

Contributors

oubowu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.