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) {
}
&#