Android -- 动画效果收获(1)

时间:2023-03-08 20:32:52

加载选项菜单
    
    MenuInflater inflater = getMenuInflater();
    inflater.inflater(R.menu.menu,menu);

Android动画速率

AccelerateDecelerateInterpolator    @android:res/anim/accelerate_decelerate_interpolator    先加速再减速
    AccelerateInterpolator                @android:res/anim/accelerate_interpolator                加速
    AnticipateInterpolator                @android:res/anim/anticipate_interpolator                先回退一小步然后加速前进
    AnticipateOvershootInterpolator        @android:res/anim/anticipate_overshoot_interpolator        在上一个基础上超出终点一小步再回到终点
    BounceInterpolator                    @android:res/anim/bounce_interpolator                    最后阶段弹球效果
    CycleInterpolator                    @android:res/anim/cycle_interpolator                    周期运动
    DecelerateInterpolator                @android:res/anim/decelerate_interpolator                减速
    LinearInterpolator                    @android:res/anim/linear_interpolator                    匀速
    OvershootInterpolator                @android:res/anim/overshoot_interpolator                快速到达终点并超出一小步最后回到终点
    
设置Activity的进入和退出动画   从-100 到0 到 100 (translate 位移动画) scale 渐变
    
    Activity.overridePendingTransition (int enterAnim, int exitAnim)
    android:interpolator :定义一个动画的变化速率,也就是控制动画的进度
    fromXScale,fromYScale,         动画开始前X,Y的缩放,0.0为不显示,  1.0为正常大小  
    android:repeatCount="2"   // rotate 旋转动画中旋转的次数为2+1
    android:startOffset="500"   // 延迟500毫秒以后执行
    android:oneshot="true"  //  帧动画  表示只显示一遍,设置为false则会不停的循环播放动画
    android:fillEnabled="true"  // set 表示是否弃用Fill保持
    android:fillAfter="true"    // set 表示是否保留最后一帧状态
    
得到版本名称以及版本号

PackageManager pm = context.getPackageManager();
    PackageInfo packinfo = pm.getPackageInfo(context.getPackageName(),0);
    packinfo.versionName;  // 便可以得到版本的名称 --> String
    packinfo.versionCode;  // 得到APK的版本  -->Int
    
设置ListView中的奇数和偶数的背景图片(自定义的Adapter)
    
        在getView中 设置如下代码
            if(position%2==0){
                holder.ll.setBackgroundResource(R.drawable.call_locate_gray);
            }else{
                holder.ll.setBackgroundResource(R.drawable.call_locate_green);
            }

得到系统当前的时间和日期

Calendar localCalendar = Calendar.getInstance ( );
        int i = localCalendar.get ( 1 );        //  得到年份
        int j = 1 + localCalendar.get ( 2 );    //  得到的月份+1
        int k = localCalendar.get ( 5 );    //  得到日期
        int l = localCalendar.get ( 11 );    //  得到小时
        int i1 = localCalendar.get ( 12 );    //  得到分钟
        int i2 = localCalendar.get ( 10 );    //  得到秒数

ProgressBar  
        
        android:indeterminate="false"      //  滚动条自动在最大值和最小值之间来回移动,而true 表示根据你的进度设置现在的进度值
        android:indeterminateDrawable="@anim/loading"  // 修改默认的动画,使用自己定义的图片  -->  animation-list 为根目录

Intent

    Intent intent = new Intent (  Intent.ACTION_CALL ,Uri.parse ( "tel:" +number);   //  直接拨打电话
           Intent intent = new Intent (  Intent.ACTION_DIAL,Uri.parse ( "tel:" +number);   //   启动拨号界面