Android Studio TextView上下滚动轮播

build.gradle(projcet:...)
allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

build.gradle(Module:app)
compile 'com.github.paradoxie:AutoVerticalTextview:0.1'

代码:
private VerticalTextview textView;
private ArrayList<String> titleList = new ArrayList<String>();

private void init() {
        textView = (VerticalTextview) findViewById(R.id.text);
        titleList.add("你是天上最受宠的一架钢琴");
        titleList.add("我是丑人脸上的鼻涕");
        titleList.add("你发出完美的声音");
        titleList.add("我被默默揩去");
        titleList.add("你冷酷外表下藏着诗情画意");
        titleList.add("我已经够胖还吃东西");
        titleList.add("你踏着七彩祥云离去");
        titleList.add("我被留在这里");
        textView.setTextList(titleList);
        textView.setText(26, 5, Color.RED);//设置属性
        textView.setTextStillTime(3000);//设置停留时长间隔
        textView.setAnimTime(300);//设置进入和退出的时间间隔
        textView.setOnItemClickListener(new VerticalTextview.OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                Toast.makeText(MainActivity.this, "点击了 : " + titleList.get(position), Toast.LENGTH_SHORT).show();
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        textView.startAutoScroll();
    }

    @Override
    protected void onPause() {
        super.onPause();
        textView.stopAutoScroll();
    }

xml:
<com.paradoxie.autoscrolltextview.VerticalTextview
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#ffff"/>


发布了19 篇原创文章 · 获赞 12 · 访问量 11万+

猜你喜欢

转载自blog.csdn.net/u014051380/article/details/77574266