ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Foursquare Android顶级横幅动画

2019-10-30 01:36:46  阅读:241  来源: 互联网

标签:foursquare twitter android-animation android-image android


我们如何在android应用程序中添加缩放图像背景?它在早期版本的android twitter登陆页面(不是主页)中可用,当前在foursquare中,顶部横幅背景具有相同的动画.
您可以通过以下链接查看动画的视频.
Animation video on youtube

我在网上搜索,但找不到任何解决方案.可能是我的关键字有误.
任何指导方针将不胜感激.

解决方法:

我发现有黑客可以这样做.但是我不确定这是否是执行此操作的最佳方法.
在Android API演示中,com.example.android.apis.graphics包中有一个名为AnimateDrawables的类.使用那个理论,我完成了这项工作.

添加一个Framelayout作为基本布局,您可以在其他小部件之间添加动画视图.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/FrameLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <com.cit.testmovingbg.MovingBGView
        android:id="@+id/movingBGView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="20dp"
        android:text="@string/app_name"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#FFFFFF"
        android:textSize="35sp" />

</FrameLayout>

MovingBGView类是视图类的子类,如下所示

public class MovingBGView extends View {

    private AnimateDrawable mDrawable;

    public MovingBGView(Context context) {
        super(context);
        setFocusable(true);
        setFocusableInTouchMode(true);

        Drawable dr = context.getResources().getDrawable(R.drawable.colombo);
        dr.setBounds(0, 0, dr.getIntrinsicWidth(), dr.getIntrinsicHeight());

        Animation an = new TranslateAnimation(0, 100, 0, 200);
        an.setDuration(2000);
        an.setRepeatCount(-1);
        an.initialize(10, 10, 10, 10);

        mDrawable = new AnimateDrawable(dr, an);
        an.startNow();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.drawColor(Color.WHITE);

        mDrawable.draw(canvas);
        invalidate();
    }   
}

标签:foursquare,twitter,android-animation,android-image,android
来源: https://codeday.me/bug/20191030/1964408.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有