• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >Android > 学习笔记:下拉刷新的视图和图标的旋转,学习笔记视图

学习笔记:下拉刷新的视图和图标的旋转,学习笔记视图

作者:网友 字体:[增加 减小] 来源:互联网 时间:2017-05-26

网友通过本文主要向大家介绍了学习笔记:下拉刷新的视图和图标的旋转,学习笔记视图等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

学习笔记:下拉刷新的视图和图标的旋转,学习笔记视图


一、下拉才出现的视图

pull_to_refresh_header.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/pull_to_refresh_header"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:background="#F3F3F3">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="23dp">

        <LinearLayout 
       android:id="@+id/pull_to_refresh_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_centerHorizontal="true"> <TextView android:id="@+id/pull_to_refresh_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/pull_to_refresh_text" android:textColor="#777777" android:textSize="16sp"/> <TextView android:id="@+id/pull_to_refresh_update_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/pull_to_refresh_update_text" android:textColor="#999999" android:textSize="14sp"/> </LinearLayout> <ProgressBar android:id="@+id/pull_to_refresh_progress" android:layout_width="30dp" android:layout_height="30dp"
       android:layout_toLeftOf
="@id/pull_to_refresh_view" android:layout_marginRight="22dp" android:layout_marginTop="5dp" android:indeterminate="true" android:indeterminateDrawable="@drawable/ic_loading_refresh" android:visibility="gone"/> <ImageView android:id="@+id/pull_to_refresh_image" android:layout_width="32dp" android:layout_height="32dp" android:layout_toLeftOf="@id/pull_to_refresh_view" android:layout_marginRight="20dp" android:layout_marginTop="5dp" android:src="@drawable/ic_refresh_down" android:scaleType="centerInside" android:contentDescription="@string/app_name"/> </RelativeLayout> <View android:layout_width="match_parent" android:layout_height="15dp"/> </LinearLayout>

ic_loading_refresh.xml

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/ic_loading"
    android:fromDegrees="0"
    android:toDegrees="360"
    android:pivotX="50%"
    android:pivotY="50%" />

1、ProgressBar的indeterminate属性,代表进程的时间是否不确定。

2、黄色底的是Android Studio的提示。第一个提示的是,当LinearLayout中的Text拓展得足够长时,会与ImageView重叠,实际效果是把ImageView给覆盖了。第二个是,建议用toStartOf代替toLeftOf,用marginEnd代替marginRight等。原因和影响还没完全搞懂。

 

二、图标旋转的动画

private ImageView mPull_to_refresh_image;
private RotateAnimation mFlipAnimation;

...

        mFlipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
                RotateAnimation.RELATIVE_TO_SELF, 0.5f);
        mFlipAnimation.setInterpolator(new LinearInterpolator());
        mFlipAnimation.setDuration(250);
        mFlipAnimation.setFillAfter(true);

...

mPull_to_refresh_image.startAnimation(mFlipAnimation);

 

1、构造方法:

    public RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue,
            int pivotYType, float pivotYValue)

(1)toDegrees - fromDegrees < 0 就会是逆时针旋转,反之是顺时针。这是我取不同值测试出来的。水平线右边是0°,或者360°,左边是180°,或者是-180°。

(2)pivotType是枢轴类型,也就是旋转中心。RELATIVE_TO_SELF代表相对这个view本身。0.5f代表这个view一半大小的位置。

2、setInterpolator作用是设置速度器。LinearInterpolator是匀速加速器,也就是匀速播放动画。

3、setDuration作用是设置动画时长,以毫秒为单位。

4、setFillAfter作用是,当参数为true时,动画播放完后,view会维持在最终的状态。而默认值是false,也就是动画播放完后,view会恢复原来的状态。

 

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 学习笔记:下拉刷新的视图和图标的旋转,学习笔记视图

相关文章

  • 2017-05-26《Android Studio实用指南》7.1 AndroidStudio代码检查工具概述
  • 2017-07-22Android触摸事件分发机制完全解析《一》
  • 2017-05-26Android应用程序(APK)的编译打包过程,androidapk
  • 2017-05-26Android面试准备 第一天 第2-4例
  • 2017-05-26TabLayout + ViewPager,tablayoutviewpager
  • 2017-05-26如何编写高效的android代码
  • 2017-05-26android studio快捷键,androidstudio
  • 2017-05-26阅读《Android 从入门到精通》(29)——LinearLayout 等四类方法
  • 2017-05-26安卓--shape简单使用,安卓--shape
  • 2017-05-227.6.2 基于TCP协议的Socket通信(1)

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 仿拉手团购App8-- 更多模块,拉手团购app8--模块
    • For each循环中使用remove方法。,eachremove
    • linux设备驱动程序之时钟管理(3)----我的那块儿蛋糕
    • android实现无限轮播,android实现轮播
    • 安卓开源项目周报0405,安卓开源项目0405
    • 减少Building &#39;Xxx&#39; Gradle project info等待时间,buildinggradle
    • Android开发学习之路--Camera之初体验
    • RecyclerView的五大开源项目-解决办法
    • android:Activity启动模式之standard
    • Android 开源库和项目 3,android开源库项目

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有