淘宝主界面的淘宝头条

微笑为你绽放 2015-12-12 04:28:29
淘宝主界面的淘宝头条类似走马灯效果文字垂直滚动显示怎么实现的
...全文
320 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
stupid_boy1103 2016-05-05
  • 打赏
  • 举报
回复
引用 8 楼 stupid_boy1103 的回复:
[quote=引用 7 楼 qq_26763799 的回复:] [quote=引用 6 楼 stupid_boy1103 的回复:] [quote=引用 5 楼 qq_26763799 的回复:] public class AutoTextView extends TextSwitcher implements ViewSwitcher.ViewFactory { private float mHeight; private Context mContext; //mInUp,mOutUp分别构成向下翻页的进出动画 private Rotate3dAnimation mInUp; private Rotate3dAnimation mOutUp; //mInDown,mOutDown分别构成向下翻页的进出动画 private Rotate3dAnimation mInDown; private Rotate3dAnimation mOutDown; public AutoTextView(Context context) { this(context, null); // TODO Auto-generated constructor stub } public AutoTextView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.auto3d); mHeight = a.getDimension(R.styleable.auto3d_textSize, 36); a.recycle(); mContext = context; init(); } private void init() { // TODO Auto-generated method stub setFactory(this); mInUp = createAnim(-90, 0 , true, true); mOutUp = createAnim(0, 90, false, true); mInDown = createAnim(90, 0 , true , false); mOutDown = createAnim(0, -90, false, false); //TextSwitcher主要用于文件切换,比如 从文字A 切换到 文字 B, //setInAnimation()后,A将执行inAnimation, //setOutAnimation()后,B将执行OutAnimation setInAnimation(mInUp); setOutAnimation(mOutUp); } private Rotate3dAnimation createAnim(float start, float end, boolean turnIn, boolean turnUp){ final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end, turnIn, turnUp); rotation.setDuration(800); rotation.setFillAfter(false); rotation.setInterpolator(new AccelerateInterpolator()); return rotation; } //这里返回的TextView,就是我们看到的View @Override public View makeView() { // TODO Auto-generated method stub TextView t = new TextView(mContext); t.setGravity(Gravity.CENTER); t.setTextSize(13); t.setSingleLine(); t.setTextColor(mContext.getResources().getColor(android.R.color.background_light)); return t; } //定义动作,向下滚动翻页 public void previous(){ if(getInAnimation() != mInDown){ setInAnimation(mInDown); } if(getOutAnimation() != mOutDown){ setOutAnimation(mOutDown); } } //定义动作,向上滚动翻页 public void next(){ if(getInAnimation() != mInUp){ setInAnimation(mInUp); } if(getOutAnimation() != mOutUp){ setOutAnimation(mOutUp); } } class Rotate3dAnimation extends Animation { private final float mFromDegrees; private final float mToDegrees; private float mCenterX; private float mCenterY; private final boolean mTurnIn; private final boolean mTurnUp; private Camera mCamera; public Rotate3dAnimation(float fromDegrees, float toDegrees, boolean turnIn, boolean turnUp) { mFromDegrees = fromDegrees; mToDegrees = toDegrees; mTurnIn = turnIn; mTurnUp = turnUp; } @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { super.initialize(width, height, parentWidth, parentHeight); mCamera = new Camera(); mCenterY = getHeight() / 2; mCenterX = getWidth() / 2; } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX ; final float centerY = mCenterY ; final Camera camera = mCamera; final int derection = mTurnUp ? 1: -1; final Matrix matrix = t.getMatrix(); camera.save(); if (mTurnIn) { camera.translate(0.0f, derection *mCenterY * (interpolatedTime - 1.0f), 0.0f); } else { camera.translate(0.0f, derection *mCenterY * (interpolatedTime), 0.0f); } camera.rotateX(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); } } } 拿走不谢
帅哥 源码能给份不[/quote] 这个view的代码都给你了,还要啥..... https://pan.baidu.com/s/1geF0ll5 原项目下载地址[/quote] 谢啦[/quote] 这个能给不同的条目添加点击事件吗?
stupid_boy1103 2016-05-05
  • 打赏
  • 举报
回复
引用 7 楼 qq_26763799 的回复:
[quote=引用 6 楼 stupid_boy1103 的回复:] [quote=引用 5 楼 qq_26763799 的回复:] public class AutoTextView extends TextSwitcher implements ViewSwitcher.ViewFactory { private float mHeight; private Context mContext; //mInUp,mOutUp分别构成向下翻页的进出动画 private Rotate3dAnimation mInUp; private Rotate3dAnimation mOutUp; //mInDown,mOutDown分别构成向下翻页的进出动画 private Rotate3dAnimation mInDown; private Rotate3dAnimation mOutDown; public AutoTextView(Context context) { this(context, null); // TODO Auto-generated constructor stub } public AutoTextView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.auto3d); mHeight = a.getDimension(R.styleable.auto3d_textSize, 36); a.recycle(); mContext = context; init(); } private void init() { // TODO Auto-generated method stub setFactory(this); mInUp = createAnim(-90, 0 , true, true); mOutUp = createAnim(0, 90, false, true); mInDown = createAnim(90, 0 , true , false); mOutDown = createAnim(0, -90, false, false); //TextSwitcher主要用于文件切换,比如 从文字A 切换到 文字 B, //setInAnimation()后,A将执行inAnimation, //setOutAnimation()后,B将执行OutAnimation setInAnimation(mInUp); setOutAnimation(mOutUp); } private Rotate3dAnimation createAnim(float start, float end, boolean turnIn, boolean turnUp){ final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end, turnIn, turnUp); rotation.setDuration(800); rotation.setFillAfter(false); rotation.setInterpolator(new AccelerateInterpolator()); return rotation; } //这里返回的TextView,就是我们看到的View @Override public View makeView() { // TODO Auto-generated method stub TextView t = new TextView(mContext); t.setGravity(Gravity.CENTER); t.setTextSize(13); t.setSingleLine(); t.setTextColor(mContext.getResources().getColor(android.R.color.background_light)); return t; } //定义动作,向下滚动翻页 public void previous(){ if(getInAnimation() != mInDown){ setInAnimation(mInDown); } if(getOutAnimation() != mOutDown){ setOutAnimation(mOutDown); } } //定义动作,向上滚动翻页 public void next(){ if(getInAnimation() != mInUp){ setInAnimation(mInUp); } if(getOutAnimation() != mOutUp){ setOutAnimation(mOutUp); } } class Rotate3dAnimation extends Animation { private final float mFromDegrees; private final float mToDegrees; private float mCenterX; private float mCenterY; private final boolean mTurnIn; private final boolean mTurnUp; private Camera mCamera; public Rotate3dAnimation(float fromDegrees, float toDegrees, boolean turnIn, boolean turnUp) { mFromDegrees = fromDegrees; mToDegrees = toDegrees; mTurnIn = turnIn; mTurnUp = turnUp; } @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { super.initialize(width, height, parentWidth, parentHeight); mCamera = new Camera(); mCenterY = getHeight() / 2; mCenterX = getWidth() / 2; } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX ; final float centerY = mCenterY ; final Camera camera = mCamera; final int derection = mTurnUp ? 1: -1; final Matrix matrix = t.getMatrix(); camera.save(); if (mTurnIn) { camera.translate(0.0f, derection *mCenterY * (interpolatedTime - 1.0f), 0.0f); } else { camera.translate(0.0f, derection *mCenterY * (interpolatedTime), 0.0f); } camera.rotateX(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); } } } 拿走不谢
帅哥 源码能给份不[/quote] 这个view的代码都给你了,还要啥..... https://pan.baidu.com/s/1geF0ll5 原项目下载地址[/quote] 谢啦
qq_26763799 2016-05-05
  • 打赏
  • 举报
回复
引用 6 楼 stupid_boy1103 的回复:
[quote=引用 5 楼 qq_26763799 的回复:] public class AutoTextView extends TextSwitcher implements ViewSwitcher.ViewFactory { private float mHeight; private Context mContext; //mInUp,mOutUp分别构成向下翻页的进出动画 private Rotate3dAnimation mInUp; private Rotate3dAnimation mOutUp; //mInDown,mOutDown分别构成向下翻页的进出动画 private Rotate3dAnimation mInDown; private Rotate3dAnimation mOutDown; public AutoTextView(Context context) { this(context, null); // TODO Auto-generated constructor stub } public AutoTextView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.auto3d); mHeight = a.getDimension(R.styleable.auto3d_textSize, 36); a.recycle(); mContext = context; init(); } private void init() { // TODO Auto-generated method stub setFactory(this); mInUp = createAnim(-90, 0 , true, true); mOutUp = createAnim(0, 90, false, true); mInDown = createAnim(90, 0 , true , false); mOutDown = createAnim(0, -90, false, false); //TextSwitcher主要用于文件切换,比如 从文字A 切换到 文字 B, //setInAnimation()后,A将执行inAnimation, //setOutAnimation()后,B将执行OutAnimation setInAnimation(mInUp); setOutAnimation(mOutUp); } private Rotate3dAnimation createAnim(float start, float end, boolean turnIn, boolean turnUp){ final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end, turnIn, turnUp); rotation.setDuration(800); rotation.setFillAfter(false); rotation.setInterpolator(new AccelerateInterpolator()); return rotation; } //这里返回的TextView,就是我们看到的View @Override public View makeView() { // TODO Auto-generated method stub TextView t = new TextView(mContext); t.setGravity(Gravity.CENTER); t.setTextSize(13); t.setSingleLine(); t.setTextColor(mContext.getResources().getColor(android.R.color.background_light)); return t; } //定义动作,向下滚动翻页 public void previous(){ if(getInAnimation() != mInDown){ setInAnimation(mInDown); } if(getOutAnimation() != mOutDown){ setOutAnimation(mOutDown); } } //定义动作,向上滚动翻页 public void next(){ if(getInAnimation() != mInUp){ setInAnimation(mInUp); } if(getOutAnimation() != mOutUp){ setOutAnimation(mOutUp); } } class Rotate3dAnimation extends Animation { private final float mFromDegrees; private final float mToDegrees; private float mCenterX; private float mCenterY; private final boolean mTurnIn; private final boolean mTurnUp; private Camera mCamera; public Rotate3dAnimation(float fromDegrees, float toDegrees, boolean turnIn, boolean turnUp) { mFromDegrees = fromDegrees; mToDegrees = toDegrees; mTurnIn = turnIn; mTurnUp = turnUp; } @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { super.initialize(width, height, parentWidth, parentHeight); mCamera = new Camera(); mCenterY = getHeight() / 2; mCenterX = getWidth() / 2; } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX ; final float centerY = mCenterY ; final Camera camera = mCamera; final int derection = mTurnUp ? 1: -1; final Matrix matrix = t.getMatrix(); camera.save(); if (mTurnIn) { camera.translate(0.0f, derection *mCenterY * (interpolatedTime - 1.0f), 0.0f); } else { camera.translate(0.0f, derection *mCenterY * (interpolatedTime), 0.0f); } camera.rotateX(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); } } } 拿走不谢
帅哥 源码能给份不[/quote] 这个view的代码都给你了,还要啥..... https://pan.baidu.com/s/1geF0ll5 原项目下载地址
stupid_boy1103 2016-05-05
  • 打赏
  • 举报
回复
引用 5 楼 qq_26763799 的回复:
public class AutoTextView extends TextSwitcher implements ViewSwitcher.ViewFactory { private float mHeight; private Context mContext; //mInUp,mOutUp分别构成向下翻页的进出动画 private Rotate3dAnimation mInUp; private Rotate3dAnimation mOutUp; //mInDown,mOutDown分别构成向下翻页的进出动画 private Rotate3dAnimation mInDown; private Rotate3dAnimation mOutDown; public AutoTextView(Context context) { this(context, null); // TODO Auto-generated constructor stub } public AutoTextView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.auto3d); mHeight = a.getDimension(R.styleable.auto3d_textSize, 36); a.recycle(); mContext = context; init(); } private void init() { // TODO Auto-generated method stub setFactory(this); mInUp = createAnim(-90, 0 , true, true); mOutUp = createAnim(0, 90, false, true); mInDown = createAnim(90, 0 , true , false); mOutDown = createAnim(0, -90, false, false); //TextSwitcher主要用于文件切换,比如 从文字A 切换到 文字 B, //setInAnimation()后,A将执行inAnimation, //setOutAnimation()后,B将执行OutAnimation setInAnimation(mInUp); setOutAnimation(mOutUp); } private Rotate3dAnimation createAnim(float start, float end, boolean turnIn, boolean turnUp){ final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end, turnIn, turnUp); rotation.setDuration(800); rotation.setFillAfter(false); rotation.setInterpolator(new AccelerateInterpolator()); return rotation; } //这里返回的TextView,就是我们看到的View @Override public View makeView() { // TODO Auto-generated method stub TextView t = new TextView(mContext); t.setGravity(Gravity.CENTER); t.setTextSize(13); t.setSingleLine(); t.setTextColor(mContext.getResources().getColor(android.R.color.background_light)); return t; } //定义动作,向下滚动翻页 public void previous(){ if(getInAnimation() != mInDown){ setInAnimation(mInDown); } if(getOutAnimation() != mOutDown){ setOutAnimation(mOutDown); } } //定义动作,向上滚动翻页 public void next(){ if(getInAnimation() != mInUp){ setInAnimation(mInUp); } if(getOutAnimation() != mOutUp){ setOutAnimation(mOutUp); } } class Rotate3dAnimation extends Animation { private final float mFromDegrees; private final float mToDegrees; private float mCenterX; private float mCenterY; private final boolean mTurnIn; private final boolean mTurnUp; private Camera mCamera; public Rotate3dAnimation(float fromDegrees, float toDegrees, boolean turnIn, boolean turnUp) { mFromDegrees = fromDegrees; mToDegrees = toDegrees; mTurnIn = turnIn; mTurnUp = turnUp; } @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { super.initialize(width, height, parentWidth, parentHeight); mCamera = new Camera(); mCenterY = getHeight() / 2; mCenterX = getWidth() / 2; } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX ; final float centerY = mCenterY ; final Camera camera = mCamera; final int derection = mTurnUp ? 1: -1; final Matrix matrix = t.getMatrix(); camera.save(); if (mTurnIn) { camera.translate(0.0f, derection *mCenterY * (interpolatedTime - 1.0f), 0.0f); } else { camera.translate(0.0f, derection *mCenterY * (interpolatedTime), 0.0f); } camera.rotateX(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); } } } 拿走不谢
帅哥 源码能给份不
qq_26763799 2016-05-05
  • 打赏
  • 举报
回复
public class AutoTextView extends TextSwitcher implements ViewSwitcher.ViewFactory { private float mHeight; private Context mContext; //mInUp,mOutUp分别构成向下翻页的进出动画 private Rotate3dAnimation mInUp; private Rotate3dAnimation mOutUp; //mInDown,mOutDown分别构成向下翻页的进出动画 private Rotate3dAnimation mInDown; private Rotate3dAnimation mOutDown; public AutoTextView(Context context) { this(context, null); // TODO Auto-generated constructor stub } public AutoTextView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.auto3d); mHeight = a.getDimension(R.styleable.auto3d_textSize, 36); a.recycle(); mContext = context; init(); } private void init() { // TODO Auto-generated method stub setFactory(this); mInUp = createAnim(-90, 0 , true, true); mOutUp = createAnim(0, 90, false, true); mInDown = createAnim(90, 0 , true , false); mOutDown = createAnim(0, -90, false, false); //TextSwitcher主要用于文件切换,比如 从文字A 切换到 文字 B, //setInAnimation()后,A将执行inAnimation, //setOutAnimation()后,B将执行OutAnimation setInAnimation(mInUp); setOutAnimation(mOutUp); } private Rotate3dAnimation createAnim(float start, float end, boolean turnIn, boolean turnUp){ final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end, turnIn, turnUp); rotation.setDuration(800); rotation.setFillAfter(false); rotation.setInterpolator(new AccelerateInterpolator()); return rotation; } //这里返回的TextView,就是我们看到的View @Override public View makeView() { // TODO Auto-generated method stub TextView t = new TextView(mContext); t.setGravity(Gravity.CENTER); t.setTextSize(13); t.setSingleLine(); t.setTextColor(mContext.getResources().getColor(android.R.color.background_light)); return t; } //定义动作,向下滚动翻页 public void previous(){ if(getInAnimation() != mInDown){ setInAnimation(mInDown); } if(getOutAnimation() != mOutDown){ setOutAnimation(mOutDown); } } //定义动作,向上滚动翻页 public void next(){ if(getInAnimation() != mInUp){ setInAnimation(mInUp); } if(getOutAnimation() != mOutUp){ setOutAnimation(mOutUp); } } class Rotate3dAnimation extends Animation { private final float mFromDegrees; private final float mToDegrees; private float mCenterX; private float mCenterY; private final boolean mTurnIn; private final boolean mTurnUp; private Camera mCamera; public Rotate3dAnimation(float fromDegrees, float toDegrees, boolean turnIn, boolean turnUp) { mFromDegrees = fromDegrees; mToDegrees = toDegrees; mTurnIn = turnIn; mTurnUp = turnUp; } @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { super.initialize(width, height, parentWidth, parentHeight); mCamera = new Camera(); mCenterY = getHeight() / 2; mCenterX = getWidth() / 2; } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX ; final float centerY = mCenterY ; final Camera camera = mCamera; final int derection = mTurnUp ? 1: -1; final Matrix matrix = t.getMatrix(); camera.save(); if (mTurnIn) { camera.translate(0.0f, derection *mCenterY * (interpolatedTime - 1.0f), 0.0f); } else { camera.translate(0.0f, derection *mCenterY * (interpolatedTime), 0.0f); } camera.rotateX(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); } } } 拿走不谢
qq_29048185 2016-05-05
  • 打赏
  • 举报
回复
在布局中new一个textview,然后用textview的setCompoundDrawables方法给它设置一张背景,位置可以随便放
jklwan 2015-12-14
  • 打赏
  • 举报
回复
淘宝用的是自定义的viewflipper控件,天猫用的是ViewSwitcher
batuer110 2015-12-14
  • 打赏
  • 举报
回复
①自定义一个继承自TextView的类里面复写 @Override public boolean isFocused() { return super.isFocused();改成 return true; } ②布局属性里面加 android:ellipsize设置当文字过长时,该控件该如何显示。有如下值设置:”start”—-省略号显示在开头;”end” ——省略号显示在结尾;”middle”—-省略号显示在中间;”marquee” ——以跑马灯的方式显示(动画横向移动)
柒加伊 2015-12-13
  • 打赏
  • 举报
回复
重写TextView设置跑马灯特效. 网上有资料的, 搜一下.
 字节跳动,百度的 ” “威力加强版” :虽然媒体热衷于炒作“头腾大战”,字节跳动最贴切的对标其实是百度。它具备百度巅峰期的优点(技术领先、销售强势),又避免了导致百度衰落的缺点(不重视用户体验、执行力低下),从而最大限度的蚕食了百度的蛋糕。字节跳动的崛起史就是百度的坍塌史,而且这个过程还在持续;当然,微博、快手也从这个过程中受益了。  抖音 崛起 的意义与承载的野心:抖音的爆红是偶然,字节跳动短视频业务的崛起是必然。这个过程体现了字节跳动的活力和执行力,也是“求变”的结果:与今日头条相比,抖音取消信息流界面、强化关注机制、鼓励经营“私有流量”,从而取得了更大的成功。在收购 Musical.ly 之后,TikTok(抖音海外版)承载了字节跳动出海的野心,但是弱点和强项同样明显。  战略进攻方向是搜索、直播、电商带货 :与外界想象的相反,字节跳动没有把要资源投入社交和游戏,不急于与腾讯死磕。今日头条的重点是发展搜索功能、攻入百度的核心领地,在流量见顶的情况下提高变现效率。抖音的重点是发展直播,以及由此而来的电商带货模式。如果势头理想,抖音甚至可能加码自营电商,但是现阶段还是以向淘宝导流为

80,337

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧