Android仿淘宝最新向上滚动广告条,给后辈的一点建议

android:layout_gravity=“center_vertical”

android:ellipsize=“end”

android:gravity=“center_vertical”

android:lines=“2”

android:text="@string/app_name"

android:textColor="#2F4F4F"

android:textSize=“16sp” />

  • 创建自动滚动的图片控件

引入图片加载框架:

compile ‘com.github.bumptech.glide:glide:3.7.0’

package tsou.cn.loopview.view;

import android.content.Context;

import android.util.AttributeSet;

import android.view.LayoutInflater;

import android.view.View;

import android.view.animation.Animation;

import android.view.animation.DecelerateInterpolator;

import android.view.animation.TranslateAnimation;

import android.widget.FrameLayout;

import android.widget.ImageView;

import com.bumptech.glide.Glide;

import java.util.List;

import tsou.cn.loopview.R;

import tsou.cn.loopview.bean.LooperBean;

public class LooperImageView extends FrameLayout {

private List tipList;

private int curTipIndex = 0;

private long lastTimeMillis;

private static final int ANIM_DELAYED_MILLIONS = 3 * 1000;

/**

  • 动画持续时长

*/

private static final int ANIM_DURATION = 1 * 1000;

private View tv_tip_out, tv_tip_in;

private Animation anim_out, anim_in;

private int nowPosition;

public LooperImageView(Context context) {

super(context);

initTipFrame();

initAnimation();

}

public LooperImageView(Context context, AttributeSet attrs) {

super(context, attrs);

initTipFrame();

initAnimation();

}

public LooperImageView(Context context, AttributeSet attrs, int defStyleAttr) {

super(context, attrs, defStyleAttr);

initTipFrame();

initAnimation();

}

private void initTipFrame() {

tv_tip_out = newView();

tv_tip_in = newView();

addView(tv_tip_in);

addView(tv_tip_out);

}

private View newView() {

View inflate = LayoutInflater.from(getContext()).inflate(R.layout.item_looper_image, null);

return inflate;

}

private void initAnimation() {

anim_out = newAnimation(0, -1);

anim_in = newAnimation(1, 0);

anim_in.setAnimationListener(new Animation.AnimationListener() {

@Override

public void onAnimationStart(Animation animation) {

}

&#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值