Android layoutAnimation详解及应用

发布时间 - 2026-01-11 00:56:58    点击率:

 Android layoutAnimation详解及应用

前言:

最近在玩一个APP的时候,发现刚进入他的页面,他页面的子控件都是从右侧飞过来的,感觉好牛的样子,就顺便模仿了一个。看着确实是比死板呆在那舒服多了!

还是感觉很好看!反正我觉得比死板呆在那好看!你们觉得那!

在看咱们模仿的:

差不多,在微调一下就好了!

上点代码,其实很简单:

首先新建一个anim文件夹在里面新建两个xml

<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" 
    android:delay="90%" //空间的执行间隔 
    android:animation="@anim/trans" /> 
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> 
  <translate  
    android:fromXDelta="100%p" android:toXDelta="0" 
    android:duration="200" /> 
  <alpha 
    android:fromAlpha="0" android:toAlpha="1" 
    android:duration="200" 
    /> 
</set> 

只要把这个动画在布局里面设置一下就出现这个效果,碉堡了!

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" 
  android:background="#e6e6e6" 
  android:layoutAnimation="@anim/anim" 
  android:orientation="vertical" > 
 
  <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center|left" 
    android:background="#ffffff" 
    android:layout_margin="5dip" 
    android:orientation="horizontal" > 
 
    <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_launcher" /> 
 
    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="TextView" /> 
  </LinearLayout> 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center|left" 
    android:background="#ffffff" 
    android:layout_margin="5dip" 
    android:orientation="horizontal" > 
 
    <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_launcher" /> 
 
    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="TextView" /> 
  </LinearLayout> 
  <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center|left" 
    android:background="#ffffff" 
    android:layout_margin="5dip" 
    android:orientation="horizontal" > 
 
    <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_launcher" /> 
 
    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="TextView" /> 
  </LinearLayout> 
  <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center|left" 
    android:background="#ffffff" 
    android:layout_margin="5dip" 
    android:orientation="horizontal" > 
 
    <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_launcher" /> 
 
    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="TextView" /> 
  </LinearLayout> 
  <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center|left" 
    android:background="#ffffff" 
    android:layout_margin="5dip" 
    android:orientation="horizontal" > 
 
    <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_launcher" /> 
 
    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="TextView" /> 
  </LinearLayout> 
  <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center|left" 
    android:background="#ffffff" 
    android:layout_margin="5dip" 
    android:orientation="horizontal" > 
 
    <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_launcher" /> 
 
    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="TextView" /> 
  </LinearLayout> 
  <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center|left" 
    android:background="#ffffff" 
    android:layout_margin="5dip" 
    android:orientation="horizontal" > 
 
    <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_launcher" /> 
 
    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="TextView" /> 
  </LinearLayout> 
</LinearLayout> 

就这么简单的几句话,感觉用户体验顿时上升了不少!真是细节决定成败啊!

 感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!


# Android layoutAnimation  # Android layoutAnimation详解  # Android layoutAnimation应用  # 呆在  # 看着  # 我觉得  # 是从  # 要把  # 希望能  # 在里面  # 谢谢大家  # 几句话  # 很好看  # 新建一个  # 其实很简单  # 决定成败  # 就好了  # 就这么  # 上升了  # delay  # apk  # http  # schemas 


相关栏目: 【 网站优化151355 】 【 网络推广146373 】 【 网络技术251813 】 【 AI营销90571


相关推荐: 微信小程序 canvas开发实例及注意事项  Laravel如何发送系统通知?(Notification渠道示例)  哪家制作企业网站好,开办像阿里巴巴那样的网络公司和网站要怎么做?  焦点电影公司作品,电影焦点结局是什么?  关于BootStrap modal 在IOS9中不能弹出的解决方法(IOS 9 bootstrap modal ios 9 noticework)  北京网站制作的公司有哪些,北京白云观官方网站?  Laravel如何处理和验证JSON类型的数据库字段  Internet Explorer官网直接进入 IE浏览器在线体验版网址  Laravel如何实现API资源集合?(Resource Collection教程)  购物网站制作费用多少,开办网上购物网站,需要办理哪些手续?  电视网站制作tvbox接口,云海电视怎样自定义添加电视源?  如何打造高效商业网站?建站目的决定转化率  JavaScript模板引擎Template.js使用详解  高端网站建设与定制开发一站式解决方案 中企动力  Laravel Seeder填充数据教程_Laravel模型工厂Factory使用  如何有效防御Web建站篡改攻击?  如何快速重置建站主机并恢复默认配置?  php json中文编码为null的解决办法  UC浏览器如何设置启动页 UC浏览器启动页设置方法  网站制作报价单模板图片,小松挖机官方网站报价?  如何在 Telegram Web View(iOS)中防止键盘遮挡底部输入框  制作网站软件推荐手机版,如何制作属于自己的手机网站app应用?  bing浏览器学术搜索入口_bing学术文献检索地址  Laravel软删除怎么实现_Laravel Eloquent SoftDeletes功能使用教程  Laravel如何安装使用Debugbar工具栏_Laravel性能调试与SQL监控插件【步骤】  Laravel怎么处理异常_Laravel自定义异常处理与错误页面教程  惠州网站建设制作推广,惠州市华视达文化传媒有限公司怎么样?  javascript中对象的定义、使用以及对象和原型链操作小结  Laravel怎么创建自己的包(Package)_Laravel扩展包开发入门到发布  如何基于PHP生成高效IDC网络公司建站源码?  iOS验证手机号的正则表达式  Midjourney怎样加参数调细节_Midjourney参数调整技巧【指南】  Laravel如何编写单元测试和功能测试?(PHPUnit示例)  如何使用 jQuery 正确渲染 Instagram 风格的标签列表  Laravel怎么实现验证码(Captcha)功能  Laravel如何使用查询构建器?(Query Builder高级用法)  创业网站制作流程,创业网站可靠吗?  jquery插件bootstrapValidator表单验证详解  javascript中闭包概念与用法深入理解  Java解压缩zip - 解压缩多个文件或文件夹实例  Laravel怎么使用Session存储数据_Laravel会话管理与自定义驱动配置【详解】  如何快速搭建自助建站会员专属系统?  Laravel如何配置Horizon来管理队列?(安装和使用)  高性价比服务器租赁——企业级配置与24小时运维服务  最好的网站制作公司,网购哪个网站口碑最好,推荐几个?谢谢?  Laravel如何使用Collections进行数据处理?(实用方法示例)  北京企业网站设计制作公司,北京铁路集团官方网站?  php8.4header发送头信息失败怎么办_php8.4header函数问题解决【解答】  怎么制作网站设计模板图片,有电商商品详情页面的免费模板素材网站推荐吗?  JS中使用new Date(str)创建时间对象不兼容firefox和ie的解决方法(两种)